codegurukool.com · Free coding tutorials & online compiler

Home › Kubernetes Tutorial › Scaling and rolling updates

Scaling and rolling updates

Change replicas and update without downtime.

kubectl scale changes the number of replicas. kubectl set image starts a rolling update: new Pods start while old ones stop, one batch at a time. If something goes wrong, kubectl rollout undo returns to the previous version.

Example code

kubectl scale deployment web --replicas=5
kubectl set image deployment/web nginx=nginx:1.27.1
kubectl rollout status deployment/web
kubectl rollout undo deployment/web

Run this code in the online editor

← DeploymentsServices →