In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Basic apiVersion: apps/v1kind: Deploymentmetadata: name: myapp-deploy namespace: defaultspec: replicas: 2 selector: matchLabels: app: myapp release: dev template: metadata: labels: app: myapp release: dev spec: containers:-name: myapp-rongqi image: ikubernetes/myapp:v12. Rolling upgrade
Vim de.yaml # modify the image version in yaml
ApiVersion: apps/v1kind: Deploymentmetadata: name: myapp-deploy namespace: defaultspec: replicas: 5 selector: matchLabels: app: myapp release: dev strategy: rollingUpdate: # sets the policy to rolling updates, as well as a reconstruction update MaxSurge: 1 # can exceed the preset value 1 container maxUnavailable: 0 # a maximum of 0 containers can be unavailable, and 6 containers can be updated as a whole. You must ensure that 5 containers are available: template: metadata: labels: app: myapp release: dev spec: containers:-name: myapp-rongqi image: ikubernetes/myapp:v1
Kubectl apply-f de.yaml # updates the configuration with apply
[root@cs25] # kubectl get pod-l app=myapp-wNAME READY STATUS RESTARTS AGEmyapp-deploy-576d479bcc-bt7hz 1 Running 0 47mmyapp-deploy-576d479bcc-bzqwv 1 11mmyapp-deploy-576d479bcc 1 Running 0 11mmyapp-deploy-576d479bcc-hf6kb 1 47mmyapp-deploy-576d479bcc-hgb6w 0 47mmyapp-deploy-576d479bcc-hgb6w 1 Running 0 11mmyapp-deploy-576d479bcc -vztqp 1 + 1 Running 0 11mmyapp-deploy-7f969b64fb-2frdn 0 * 0smyapp-deploy-7f969b64fb-5ms8f 0/1 Pending 0 0smyapp-deploy-7f969b64fb-5ms8f 0/1 Pending 0 0smyapp-deploy-7f969b64fb-6lhjw 0/1 ContainerCreating 0 1smyapp-deploy-7f969b64fb-2frdn 0/1 ContainerCreating 0 1smyapp-deploy-7f969b64fb-5ms8f 0/1 ContainerCreating 0 0smyapp-deploy-7f969b64fb-2frdn 0/1 ContainerCreating 0 35smyapp-deploy-7f969b64fb-5ms8f 0ax 1 ContainerCreating 0 35smyapp-deploy-7f969b64fb-6lhjw 0ax 1 ContainerCreating 0 36smyapp-deploy-576d479bcc-vztqp 0 Terminating 0 12mmyapp-deploy-576d479bcc-vztqp 0 12mmyapp-deploy-576d479bcc-vztqp 0 Terminating 0 12mmyapp-deploy-576d479bcc-vztqp 0 Chart 1 Terminating 0 12m MyApplyMuir 7f969b64fb- 5ms8f 1/1 Running 0 43smyapp-deploy-7f969b64fb-2frdn 1/1 Running 0 47smyapp-deploy-7f969b64fb-6lhjw 1/1 Running 0 51smyapp-deploy-576d479bcc-hgb6w 1/1 Terminating 0 13mmyapp-deploy-576d479bcc-bzqwv 1/1 Terminating 0 13mmyapp-deploy-576d479bcc -bt7hz 1 + 1 Terminating 0 49mmyapp-deploy-7f969b64fb-gprvk 0 * Deploy-7f969b64fb-fwdbr 0/1 ContainerCreating 0 1smyapp-deploy-7f969b64fb-gprvk 0/1 ContainerCreating 0 1smyapp-deploy-576d479bcc-hgb6w 0/1 Terminating 0 13mmyapp-deploy-576d479bcc-bzqwv 0/1 Terminating 0 13mmyapp-deploy-7f969b64fb-fwdbr 0/1 ContainerCreating 0 18smyapp-deploy-7f969b64fb-gprvk 0/1 ContainerCreating 0 19smyapp-deploy-576d479bcc-hgb6w 0/1 Terminating 0 13mmyapp-deploy-576d479bcc-bt7hz 0/1 Terminating 0 49mmyapp-deploy-576d479bcc-bzqwv 0/1 Terminating 0 13mmyapp-deploy-7f969b64fb-gprvk 1/1 Running 0 20smyapp-deploy-7f969b64fb-fwdbr 1/1 Running 0 20s
Kubectl get rs-o wide # use the command to view
You can see that the current image version has been changed to v2 and the template has also changed. The previous v1 version also ensures that it is convenient to roll back. Each modification of the content of the yaml file will be regarded as an update, and the last string of numbers is calculated through the yaml file.
Note: a new revision will be created only when the pod template of deployment is changed. For example, updating template tags or container images can trigger scrolling updates. Other operations, such as expanding the number of copies, will not trigger deployment update operations.
Canary release
Kubectl set image deploy myapp-deploy myapp-rongqi=ikubernetes/myapp:v3 & & kubectl rollout pause deploy myapp-deploy
# kubectl set image deploy "Controller Name"Container name" = ikubernetes/myapp:v3 & & kubectl rollout pause deploy "Controller Name"
# the principle is to upgrade the version of a container first, execute pause to pause the upgrade task, and release the pause after the upgraded container has been tested by a real user.
Kubectl get rs-o wide # looking at the controller, you can see that there are 1 v3 version, 5 v2 versions, and 6 because my rolling policy defines the upgrade to allow 6.
Kubectl rollout resume deploy myapp-deploy
# lift the pause
# after lifting the pause, you can see that the v2 version is transferred to the v3 version after a little shutdown, and finally all the v2 is closed, and all five containers of the v3 version are all online normally.
Rollback kubectl rollout history deployment/nginx-deployment# View upgrade History kubectl rollout history deployment/nginx-deployment-- revision=2# View details of an upgrade History kubectl rollout undo deployment/nginx-deployment# rollback to the previous version kubectl rollout undo deployment/nginx-deployment-- to-revision=2# rollback to the specified version
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.