Deployment manifest essentials
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
spec:
containers:
- name: api
image: myapp:1.2.3
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "500m"
memory: "512Mi"
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
Always set resource requests and limits
Without requests, the scheduler places pods on any node regardless of available resources. Without limits, a runaway process starves other pods on the same node.
Readiness vs liveness probes
- Readiness — is this pod ready to receive traffic? Failed readiness removes the pod from the Service endpoint list.
- Liveness — is this pod alive? Failed liveness restarts the container.
Horizontal Pod Autoscaler
kubectl autoscale deployment api --min=2 --max=10 --cpu-percent=70