Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Kubernetes rolling update

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Examples:

Creating an app:

kubectl create deployment nginx --image=nginx:1.11

create a service

kubectl expose deployment nginx --port=80 --type=NodePort

Expansion and contraction:

kubectl scale deployment nginx --replicas=5

Modify Mirror, Scroll Update:

kubectl set image deployment nginx nginx=nginx:1.10

or

kubectl edit deployment/nginx

View update status:

kubectl rollout status deployment nginx

terminate upgrade

kubectl rollout pause deployment/nginx

continue to upgrade

kubectl rollout resume deployment/nginx

rollback

kubectl rollout undo deployment/nginx

Rollback to a specified version

kubectl rollout undo deployment/nginx --to-revision=2

View the scrolling version:

kubectl rollout history deployment nginx

View information:

kubectl describe deployment/nginx

Several important parameters are explained.

maxSurge and maxUnavailable

maxSurge: 1 indicates that 1 pod will be started first when rolling upgrade

maxUnavailable: 1 indicates the maximum number of Unavailable pods allowed during rolling upgrade

Since the replicas are 3, the total number of pods is between 2 and 4.

terminationGracePeriodSeconds

The k8s will send a SIGTERM signal to the app, which can be used to close the app correctly and gracefully, with a default of 30 seconds.

If a more elegant shutdown is required, use the configuration statement provided by k8s for the pre-stop lifecycle hook, which will be executed before sending the SIGTERM.

livenessProbe vs. readinessProbe

livenessProbe is kubernetes think the pod is alive, if it does not exist, you need to kill it, and then start a new one to reach the number specified by replicas.

readinessProbe is kubernetes think that the pod is successfully started, here according to the characteristics of each application, to judge by themselves, you can execute command, you can also httpGet. For example, for applications using Java web services, it is not simply that tomcat can provide services to the outside world after successful startup, but also need to wait for the initialization of spring container, database connection, etc. For spring boot applications, the default actuator has the/health interface, which can be used to determine the success of the boot.

ReadinessProbe. initialDelay Seconds can be set to the minimum time required for the system to fully boot, livenessProbe. initialDelay Seconds can be set to the maximum time required for the system to fully boot + several seconds.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report