A rolling update is to update only a small number of copies at a time, and after success, update more copies, and finally complete the update of all copies. The biggest benefit of rolling update is zero downtime, and there is always a copy running throughout the update process, thus ensuring business continuity.
Next, we deploy the three-copy application, the initial image is httpd:2.2.31, and then update it to httpd:2.2.32.
The configuration file of httpd:2.2.31 is as follows:
by kubectl apply
deploying.
The deployment process is as follows:
-
Create Deployment
httpd
-
Create ReplicaSet
httpd-551879778
-
Create three pods
-
The current image is
httpd:2.2.31
httpd:2.2.31
Replace in the configuration file with httpd:2.2.32
and execute again kubectl apply
.
We found the following changes:
-
Deployment
httpd
's mirror updated tohttpd:2.2.32
-
A ReplicaSet is newly created
httpd-1276601241
, mirrored ashttpd:2.2.32
, and three new Pods are managed. -
httpd-551879778
There are no Pods in the previous ReplicaSet .
The conclusion is: httpd-551879778
the three Pods of the httpd:2.2.31
ReplicaSet have been replaced httpd-1276601241
by the three Pods of the ReplicaSet httpd:2.2.32
.
The specific process can be kubectl describe deployment httpd
viewed through.
Update and replace only one Pod at a time:
-
The ReplicaSet
httpd-1276601241
adds one Pod to a total of 1. -
The ReplicaSet
httpd-551879778
reduces one Pod to a total of 2. -
The ReplicaSet
httpd-1276601241
adds one Pod to a total of 2. -
The ReplicaSet
httpd-551879778
reduces one Pod to a total of 1. -
The ReplicaSet
httpd-1276601241
adds one Pod to a total of 3. -
The ReplicaSet
httpd-551879778
reduces one Pod to a total of 0.
The number of Pods replaced per replacement is customizable. Kubernetes provides two parameters maxSurge
and maxUnavailable
to finely control the number of Pod replacements, which we will discuss later in conjunction with the Health Check feature.
In the next section we discuss how to roll back.
Books:
1. "Play with Docker Container Technology in 5 Minutes a Day"
https://item.jd.com/16936307278.html
2. "Fun with OpenStack for 5 minutes a day"
https://item.jd.com/12086376.html