如何在不更改 kubernetes 中的部署 yaml 的情况下滚动重启 pod? [英] How to rolling restart pods without changing deployment yaml in kubernetes?
本文介绍了如何在不更改 kubernetes 中的部署 yaml 的情况下滚动重启 pod?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 kubernetes 中有滚动更新(自动无需停机)但没有滚动重启,至少我找不到.我们必须更改部署 yaml.有没有办法让滚动重启",最好不改变部署yaml?
解决方案
在 kubernetes 1.15 之前,答案是否定的.但是有一种使用虚拟注释修补部署规范的解决方法:
kubectl 补丁部署 web -p "{"spec":{"template":{"metadata":{"annotations":{"date":"`date +'%s'`"}}}}}"
从 kubernetes 1.15 开始,您可以使用:
kubectl rollout restart deployment your_deployment_name
<块引用>
- 创建了一个新的
kubectl rollout restart
命令,用于滚动重启部署. kubectl rollout restart
现在适用于 DaemonSets 和 StatefulSets
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?
解决方案
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'`"}}}}}"
As of kubernetes 1.15 you can use:
kubectl rollout restart deployment your_deployment_name
- 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文