Kubernetes detailed explanation (twenty-five) - Deployment controller expansion

Today, I will continue to introduce the relevant knowledge of Linux operation and maintenance. The main content of this article is the expansion of the Deployment controller.

1. Introduction to Deployment Controller Capacity Expansion

The Deployment controller supports expansion and supports three types of expansion commands. Next, I will describe these three expansion commands in detail.
First, we first create a Deployment controller, the name of the controller is deployment, and there is only one Pod under the controller, as shown below:
insert image description here

2. Scale mode expansion

First, we try to scale the controller using the scale command.
Excuting an order:

kubectl scale deployment/deployment --replicas=2

The Pods under the Deployment controller can be expanded to 2, and the results are as follows:
insert image description here

Three, apply method expansion

Next, we try to use the apply method to expand. To use the apply method to expand the capacity, is to modify the resource configuration list of the Deployment, and configure the number of replicas of the pod in it.
We configure the Pod capacity to 3 in the resource configuration list, and then execute the command:

kubectl apply -f Deployment.yaml

Recreate the Deployment controller, and the result is as follows:
insert image description here
As can be seen from the above figure, the number of Pods under the Deployment controller becomes 3.

Fourth, patch expansion

Finally, we use the patch method to expand. The expansion method of patch is equivalent to applying a patch to the already running Deployment controller. We can use the patch command to modify the replicas parameters of the Deployment controller, so that the expansion of the Pod under the Deployment can be achieved.
Below, we expand the number of Pods under the Deployment controller from 3 to 4, and execute the command:

kubectl patch deployment deployment -p '{"spec":{"replicas":4}}'

The execution result of this command is as follows:
insert image description here
As can be seen from the above figure, our Deployment controller has been successfully expanded!
Originality is not easy, please indicate the source for reprinting: https://blog.csdn.net/weixin_40228200

Guess you like

Origin blog.csdn.net/weixin_40228200/article/details/124416741