Scaling up and down in Kubernetes cluster
In the previous section, we mentioned that a ReplicaSet ensures that the user-specified number of pod replicas is running at any given time. To manage replicas with the ReplicaSet, we have to define a configuration file with a replica count for a pod. This configuration can be changed at runtime.
Getting ready
Make sure that the Kubernetes setup is running, as described in the preceding recipe, and that you are in the Kubernetes directory, which was created with the preceding installation.
How to do it...
Follow these steps:
- Start the nginx container with a replica count of 3:
$ kubectl run my-nginx --image=nginx --replicas=3 --port=80
- This will start three replicas of the nginx container. List the pods to get the status as shown in the following screenshot:
$ kubectl get pods

- Get the ReplicatSet configuration:
$ kubectl get rs

As you can see, we have a my-nginx
controller, which has a replica count of 3
.
Scale down to a replica of 1 and update...