Restarting Resources in Kubernetes v1.15+

Christian Emmer
Christian Emmer
Jul 9, 2020 · 1 min read
Restarting Resources in Kubernetes v1.15+

Restarting resources such as deployments in Kubernetes is a fairly common task, and starting with Kubernetes v1.15 there's an easy command for it.

Kubernetes v1.15 was released on Jun 19, 2019. See "Restarting Deployments in Kubernetes Before v1.15" for the older method.

Restarting Deployments in Kubernetes Before v1.15
Restarting Deployments in Kubernetes Before v1.15
Jul 10, 2020 · 2 min read

Restarting resources such as deployments in Kubernetes is a fairly common task, but before v1.15 it wasn't very straight-forward.

There are a bunch of reasons why you'd want to restart a resource in Kubernetes:

  • The code running in a pod is in a "hung" state and liveness probes don't exist or aren't ejecting it.
  • A config map has changed and a deployment restart is needed for it to be applied.
  • You're doing some low-grade chaos engineering and want to check for crash/restart tolerance.
  • And more!

Thankfully there's an easy command to restart different types of resources:

kubectl rollout restart <resource>

According to the changelog , here's the different resources that are supported right now:

  • Deployments
  • Daemon sets
  • Stateful sets

Here's a quick example of how to restart a deployment named api:

$ kubectl rollout restart deployment/api
deployment.extensions/api restarted

Happy hacking!