Deployments & Scaling
Intermediate
Overview
A Deployment declares the desired state for a set of identical Pods: which image to run and how many replicas. Kubernetes continuously works to match reality to that desired state.
Scaling is a one-liner: kubectl scale. Updating the image triggers a rolling update, replacing Pods gradually so there is no downtime. If something breaks, you can roll back.
kubectl rollout status and kubectl rollout undo are your friends during and after a release.
Cheatsheet
kubectl get deploymentsList deploymentskubectl scale deploy/api --replicas=5Scale to 5 podskubectl set image deploy/api api=app:2.0Trigger a rolling updatekubectl rollout status deploy/apiWatch a rolloutkubectl rollout undo deploy/apiRoll back to the previous versionTry it
A safe, simulated terminal. Run the suggested commands to see typical output.
simulated terminal
Type a command and press Enter, or click a suggestion below to run it.
Quick quiz
1. What does a Deployment primarily manage?
2. Which command rolls back a bad release?