1. Deploying to AWS Elastic Beanstalk
| Step |
Detail |
| 1 |
Create EB application + environment (Java platform) |
| 2 |
Set listening port via PORT env |
| 3 |
Upload fat JAR via eb deploy |
| 4 |
Configure env vars in EB console (Configuration → Software) |
2. Deploying to AWS ECS/Fargate
Example: ECS Fargate task definition
{
"family": "orders",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "512", "memory": "1024",
"containerDefinitions": [{
"name": "app",
"image": "ghcr.io/myorg/orders:1.0",
"portMappings": [{ "containerPort": 8080 }],
"environment": [{ "name": "SPRING_PROFILES_ACTIVE", "value": "prod" }],
"healthCheck": {
"command": ["CMD-SHELL","wget -qO- http://localhost:8080/actuator/health/liveness || exit 1"]
}
}]
}
3. Deploying to Heroku (Procfile)
Example: Heroku Procfile
# Procfile
web: java -Dserver.port=$PORT -jar target/app.jar
# system.properties
java.runtime.version=21
4. Deploying to Google Cloud Run
Example: Deploy to Google Cloud Run
gcloud builds submit --tag gcr.io/PROJECT/orders:1.0
gcloud run deploy orders \
--image gcr.io/PROJECT/orders:1.0 \
--platform managed --region us-central1 \
--allow-unauthenticated \
--set-env-vars SPRING_PROFILES_ACTIVE=prod
5. Deploying to Azure App Service
Example: Deploy to Azure App Service
az webapp create -g rg -p plan -n my-orders --runtime "JAVA:21-java21"
az webapp deploy -g rg -n my-orders --src-path target/app.jar --type jar
az webapp config appsettings set -g rg -n my-orders \
--settings SPRING_PROFILES_ACTIVE=prod
6. Deploying to Kubernetes (Deployment, Service)
Example: Kubernetes Deployment manifest
apiVersion: apps/v1
kind: Deployment
metadata: { name: orders }
spec:
replicas: 3
selector: { matchLabels: { app: orders } }
template:
metadata: { labels: { app: orders } }
spec:
containers:
- name: app
image: ghcr.io/myorg/orders:1.0
ports: [{ containerPort: 8080 }]
envFrom: [{ configMapRef: { name: orders-config } }, { secretRef: { name: orders-secret } }]
livenessProbe: { httpGet: { path: /actuator/health/liveness, port: 8080 }, initialDelaySeconds: 30 }
readinessProbe: { httpGet: { path: /actuator/health/readiness, port: 8080 }, initialDelaySeconds: 10 }
---
apiVersion: v1
kind: Service
metadata: { name: orders }
spec:
selector: { app: orders }
ports: [{ port: 80, targetPort: 8080 }]
type: ClusterIP
7. Creating Kubernetes ConfigMaps and Secrets
Example: Create ConfigMap and Secret
kubectl create configmap orders-config \
--from-literal=SPRING_PROFILES_ACTIVE=prod \
--from-literal=APP_FEATURE_X_ENABLED=true
kubectl create secret generic orders-secret \
--from-literal=SPRING_DATASOURCE_PASSWORD=$DB_PASSWORD
| Platform |
Endpoint Used |
| K8s liveness |
/actuator/health/liveness |
| K8s readiness |
/actuator/health/readiness |
| AWS ALB target group |
/actuator/health |
| Cloud Run startup |
Listen on $PORT within timeout |
9. Using Cloud-Native Buildpacks
Example: Build OCI image with Buildpacks
./mvnw spring-boot:build-image \
-Dspring-boot.build-image.imageName=ghcr.io/myorg/orders:1.0
# OR
pack build ghcr.io/myorg/orders:1.0 \
--builder paketobuildpacks/builder-jammy-base
10. Configuring Auto-Scaling Policies
Example: Horizontal Pod Autoscaler
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata: { name: orders }
spec:
scaleTargetRef: { apiVersion: apps/v1, kind: Deployment, name: orders }
minReplicas: 3
maxReplicas: 20
metrics:
- type: Resource
resource: { name: cpu, target: { type: Utilization, averageUtilization: 70 } }
11. Using Spring Cloud Kubernetes
Example: Spring Cloud Kubernetes dependencies
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-client-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-client-discovery</artifactId>
</dependency>
Note: Reads ConfigMap/Secret as Spring property
sources and uses K8s Service objects for discovery.