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 deployments
kubectl scale deploy/api --replicas=5Scale to 5 pods
kubectl set image deploy/api api=app:2.0Trigger a rolling update
kubectl rollout status deploy/apiWatch a rollout
kubectl rollout undo deploy/apiRoll back to the previous version

Try 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?