Scale up and down manually with the kubectl scale command

Assume that today we'd like to scale our nginx Pods from two to four:

// kubectl scale --replicas=<expected_replica_num> deployment <deployment_name># kubectl scale --replicas=4 deployment my-nginxdeployment "my-nginx" scaled

Let's check how many pods we have now:

# kubectl get podsNAME READY STATUS RESTARTS AGEmy-nginx-6484b5fc4c-9v7dc 1/1 Running 0 1mmy-nginx-6484b5fc4c-krd7p 1/1 Running 0 1mmy-nginx-6484b5fc4c-nsvzt 0/1 ContainerCreating 0 2smy-nginx-6484b5fc4c-v68dr 1/1 Running 0 2s

We could find two more Pods are scheduled. One is already running and another one is creating. Eventually, we will have four Pods up and running if we have enough compute resources.

Kubectl scale (also ...

Get Kubernetes Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.