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

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)