Understanding Kubernetes Deployment Controller and Rolling Updates
This article explains the core functions of the Kubernetes Deployment controller, describes how rolling updates and canary releases work, provides a sample Deployment YAML, and demonstrates common kubectl commands for inspecting, updating, and rolling back deployments in a cloud‑native environment.
The Deployment controller in Kubernetes manages stateless application services, handling pod and ReplicaSet lifecycle, providing features such as deployment, replica control, rolling updates, and rollbacks.
Rolling upgrades update instances in batches rather than all at once, reducing downtime. The controller reduces the old ReplicaSet replicas to zero while scaling the new ReplicaSet to the desired count. Two update strategies exist: Recreate (delete all old pods then create new ones) and RollingUpdate , which updates pods incrementally using maxUnavailable and maxSurge parameters.
Example Deployment manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
name: haha-deploy
namespace: dev
spec:
replicas: 5
revisionHistoryLimit: 5 # keep 5 historical versions
strategy:
type: RollingUpdate
selector:
matchLabels:
app: haha-nginx-pod
template:
metadata:
labels:
app: haha-nginx-pod
spec:
containers:
- name: haha-nginx
image: nginx:1.23.0To view controller parameters:
[root@master ~]# kubectl describe deploy haha-deploy -n devRolling update the nginx image and record the change:
[root@master ~]# kubectl set image deployment/haha-deploy haha-nginx=nginx:1.23.0 -n dev --record=trueMonitor the upgrade process in real time:
[root@master ~]# kubectl get pods -n dev -wRollout commands for history, undo, pause, resume, and status:
[root@master ~]# kubectl rollout history deployment/haha-deploy -n dev [root@master ~]# kubectl rollout undo deployment/haha-deploy -n dev --to-revision=2 [root@master ~]# kubectl rollout pause deployment/haha-deploy -n dev [root@master ~]# kubectl rollout resume deployment/haha-deploy -n dev [root@master ~]# kubectl rollout status deployment/haha-deploy -n devThese commands allow operators to manage deployment versions, view change history, and safely roll back to previous releases, supporting continuous delivery in cloud‑native environments.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.