Interactive Lab ยท CKA Topic ยท Beginner to Intermediate

DEPLOYMENTS & ROLLING UPDATES

$ kubectl set image deployment/webapp nginx=nginx:1.25
๐Ÿš€ Step 1 Create a Deployment
  • 1A Deployment manages a ReplicaSet, which manages Pods. It ensures the desired number of replicas are always running.
  • 2Key fields: replicas sets how many pods to run, selector.matchLabels connects the Deployment to its pods, and template is the pod spec.
  • 3Apply this Deployment and watch the pod visualizer show your 3 running pods.
Pod Visualizer
No deployment
Apply a deployment to see pods here.
deployment.yaml
Deployment Status
NameNone
Replicas0/0
ImageNone
StrategyNone
StatusNot deployed
terminalLIVE
๐Ÿ“ˆ Step 2 Scale the Deployment
  • 1Scaling a Deployment changes the number of replica pods. Kubernetes adds or removes pods to match the new replica count.
  • 2You can scale imperatively with kubectl scale deployment webapp --replicas=5 or declaratively by editing the YAML and applying.
  • 3Use the slider below to choose a replica count, then apply. Watch the pod visualizer update.
Pod Visualizer
Waiting...
Complete Step 1 first.
Scale Replicas
3
replicas
terminalLIVE
๐Ÿ”„ Step 3 Rolling Update
  • 1A Rolling Update replaces pods one at a time, ensuring zero downtime. The old pods are only removed once new ones are healthy.
  • 2maxSurge: 1 allows one extra pod during the update. maxUnavailable: 1 allows one pod to be down at a time.
  • 3Change the image from nginx:1.24 to nginx:1.25 and apply. Watch the animated rolling update in the visualizer.
Rolling Update Visualizer
v1.24
Complete Step 1 first.
deployment.yaml
Update Status
Current imagenginx:1.24
Target imageNot set
ProgressWaiting
terminalLIVE
โช Step 4 Rollback a Deployment
  • 1Kubernetes keeps a revision history of your Deployment. If an update causes problems, you can instantly roll back to a previous version.
  • 2kubectl rollout undo deployment/webapp rolls back one revision. Add --to-revision=1 to go to a specific version.
  • 3Click Rollback on revision 1 below and watch the deployment return to nginx:1.24.
Pod Visualizer
Current
Complete Steps 1 and 3 first.
Rollout History
No history available. Complete the update in Step 3 first.
terminalLIVE
Deployment Commands
get deploymentsList all deployments and their status.
scale deployment --replicas=NChange the number of running pods.
set image deployment/nameUpdate the container image to trigger a rollout.
rollout status deployment/nameWatch the rollout progress in real time.
rollout undo deployment/nameRoll back to the previous revision.
rollout history deployment/nameView all revisions in the rollout history.
Rolling Update Fields
strategy.typeRollingUpdate (default) or Recreate (all pods at once).
maxSurgeHow many extra pods can exist above the desired count during update.
maxUnavailableHow many pods can be unavailable during the update.
minReadySecondsSeconds a new pod must be ready before considered available.
revisionHistoryLimitHow many old ReplicaSets to keep for rollback. Default is 10.
โœ“
Achievement Unlocked
Nice work!