You have a Spring Boot service. Describe how you would containerize it and run it on Kubernetes in AWS or Azure.
Answer
- Build:
mvn clean package creates a JAR in CI; write a Dockerfile (or multi-stage build) from a small JRE image; run as a non-root user. - Push the image to a registry (ECR or ACR) with a version tag, never rely on
latest. - Kubernetes: Deployment (replicas, resource requests/limits, readiness and liveness probes pointing to
/actuator/health), Service (ClusterIP) and Ingress for HTTP. - Config: ConfigMap for settings, Secret or external secret manager for passwords; Spring profile via environment variable.
- Scaling: HorizontalPodAutoscaler on CPU or custom metrics.
- Cloud: EKS (AWS) or AKS (Azure), managed database (RDS or Azure SQL), identities via IAM role or managed identity.
- Observability: logs to stdout, metrics through Actuator and Prometheus, alerts.
Practice this question in Repaso