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

Kubernetes

Kubernetes Problem Overview


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 Solutions


Solution 1 - 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

Solution 2 - Kubernetes

If you use k9s, the restart command can be found if you select deployments, statefulsets or daemonsets:

screenshot of k9s

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmuratcavusView Question on Stackoverflow
Solution 1 - KubernetesstratovariusView Answer on Stackoverflow
Solution 2 - KubernetesBrimstedtView Answer on Stackoverflow