Kubernetes: Scale a Deployment
Scaling a Deployment is changing its replica count. Kubernetes adds Pods when the count rises and removes Pods when the count falls.
Scale up to five
One command asks for five copies. Kubernetes starts two new Pods.
kubectl scale deployment web --replicas=5Check the new count
5/5 means all five copies are ready. The app now has more capacity.
kubectl get deploymentsScale down to two
Scaling down removes Pods. Kubernetes stops three of the five copies.
kubectl scale deployment web --replicas=2See the smaller set
Two Pods remain. The app still runs, with less capacity.
kubectl get podsExample
kubectl scale deployment web --replicas=5
kubectl get deployments
kubectl get podsKey points
- Scale: change the number of copies of an app that are running.
- Use kubectl scale deployment to change the replica count of a Deployment.
- Kubernetes adds new Pods when you scale up, and it removes Pods when you scale down.
- Scaling up spreads the work across more copies of the app.
- Scaling down frees the machines the extra copies were using.
- You can also edit replicas in the manifest file and apply it again.
In this example, scale asks for five replicas instead of three. get deployments shows 5/5 ready. get pods shows five Pods. Kubernetes added two Pods and left the old three alone.
Note
Scaling changes the count only, so the image and the settings stay the same.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
Which command changes a Deployment from three replicas to five?