本文介绍了如何在不更改Kubernetes中的部署Yaml的情况下滚动重启Pod?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在kubernetes中有一个滚动更新(自动没有停机),但是没有滚动重启,至少我找不到.我们必须更改部署Yaml.有没有办法使滚动重启",最好不更改部署yaml?
In kubernetes there is a rolling update (automatically without downtime) but there is not a rolling restart, at least i could not find. We have to change deployment yaml. Is there a way to make rolling "restart", preferably without changing deployment yaml?
推荐答案
在kubernetes 1.15之前,答案是否定的.但是有一种解决方案,可以使用虚拟注释对部署规范进行修补:
Before kubernetes 1.15 the answer is no. But there is a workaround of patching deployment spec with a dummy annotation:
kubectl patch deployment web -p \
"{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"date\":\"`date +'%s'`\"}}}}}"
从kubernetes 1.15开始,您可以使用:
As of kubernetes 1.15 you can use:
kubectl rollout restart deployment your_deployment_name
- 创建了一个新的
kubectl rollout restart
命令,该命令可滚动重启部署. -
kubectl rollout restart
现在可用于DaemonSet和StatefulSets
- Created a new
kubectl rollout restart
command that does a rolling restart of a deployment. kubectl rollout restart
now works for DaemonSets and StatefulSets
这篇关于如何在不更改Kubernetes中的部署Yaml的情况下滚动重启Pod?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!