How to rolling restart pods without changing deployment yaml in kubernetes?

后端 未结 1 965
别跟我提以往
别跟我提以往 2021-02-04 23:48

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 the

相关标签:
1条回答
  • 2021-02-05 00:43

    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
    

    CLI Improvements

    • Created a new kubectl rollout restart command that does a rolling restart of a deployment.
    • kubectl rollout restart now works for DaemonSets and StatefulSets
    0 讨论(0)
提交回复
热议问题