Deployments
Harry
· 11 Sep 2026
· 9 views
Why Deployments?
A Deployment is a controller that manages a set of identical pods via a ReplicaSet. It guarantees the desired number of replicas, supports rolling updates and lets you roll back.
A Deployment Manifest
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels:
app: web
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx:alpine
ports:
- containerPort: 80Save as deployment.yaml and apply it:
kubectl apply -f deployment.yaml
kubectl get deployments
kubectl get pods -o wideScaling
kubectl scale deployment web --replicas=5
kubectl rollout status deployment/webRolling Update and Rollback
kubectl set image deployment/web web=nginx:1.27
kubectl rollout status deployment/web
kubectl rollout undo deployment/web # roll backBy default a rolling update replaces pods gradually, keeping the app available.
Key Points
- Deployment -> ReplicaSet -> Pods is the standard hierarchy.
- The
selectormust match labels on the pod template. - Rolling updates avoid downtime;
rollout undoreverts a bad release.