Deployments & Rolling Updates
A Deployment manages a set of identical Pod replicas via a ReplicaSet, ensuring desired pod counts and handling seamless, zero-downtime application updates.
1. Production Deployment Manifest
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-deployment
spec:
replicas: 3 # Maintain 3 pod instances across cluster
selector:
matchLabels:
app: api-server
template:
metadata:
labels:
app: api-server
spec:
containers:
- name: api-container
image: myusername/api:v1.0
ports:
- containerPort: 30002. Scaling & Rollout Management Commands
# 1. Imperative Scaling (Scale to 5 replicas) kubectl scale deployment/api-deployment --replicas=5 # 2. Update Image Version (Triggers Zero-Downtime Rolling Update) kubectl set image deployment/api-deployment api-container=myusername/api:v2.0 # 3. Monitor Rollout Progress kubectl rollout status deployment/api-deployment # 4. Instant Rollback to Previous Version (if bug detected!) kubectl rollout undo deployment/api-deployment
Next Up
Learn Kubernetes Services: ClusterIP, NodePort, LoadBalancer, and Service Selectors.
Next Lesson: Services & ClusterIP/NodePort →