Configuration
Deployment + Service + HPA
Production-ready app deployment with horizontal pod autoscaling.
Deployment + Service + HPA
apiVersion: apps/v1
kind: Deployment
metadata:
name: messaging-api
labels:
app: messaging-api
spec:
replicas: 3
selector:
matchLabels:
app: messaging-api
template:
metadata:
labels:
app: messaging-api
spec:
containers:
- name: api
image: registry.example.com/messaging-api:1.2.0
ports:
- containerPort: 8080
resources:
requests:
cpu: 250m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 15
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: messaging-api
spec:
selector:
app: messaging-api
ports:
- port: 80
targetPort: 8080
type: ClusterIP
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: messaging-api-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: messaging-api
minReplicas: 3
maxReplicas: 20
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
DevOps
AI
Kubernetes
Splunk
Prometheus
Linux
Cloud Providers