kubectl scale: Scaling deployments

1 min read

To be able to scale kubernetes deployments we can edit the yaml file to increase the number of replicas we want but we can also use kubectl scale. Let's try to scale out the following deployment:

$ kubectl get deploy demo
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
demo   2/2     2            2           11d

Using kubectl scale we can set a new number of replicas for a given deployment as follows:

$ kubectl scale deployment/demo --replicas=5
deployment.apps/demo scaled

We can see with kubectl get that it will spin up more replicas to reach the new target:

$ kubectl get deploy demo
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
demo   2/5     2            2           11d

After a while it will reach the new desired state:

$ kubectl get deploy demo
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
demo   5/5     5            5           11d

Posted on 09/02/2021