Post Image

Kubectl Restart Deployment

If you need to restart all of your pods in your Kubernetes deployment kubectl provides a way of doing that quickly and easily, All you need is the name of your deployment.

In this example I have a deployment 'nginx' that I want to restart all the pods for, below is the command to restart that deployment

$ kubectl rollout restart deployment nginx

This command will only do a few pods at a time so your service will continue to be up during the restart, just with a few less pods running at that time.

 

If you list your pods during the restart of the deployment you will see some pods running, some terminating, and some creating.

NAME                     READY   STATUS              RESTARTS        AGE
nginx-5b7f8d685b-5gwgp   1/1     Running             3 (27d ago)     63d
nginx-5b7f8d685b-cp5vp   1/1     Running             3 (7h8m ago)    63d
nginx-5b7f8d685b-jfknq   1/1     Running             3 (6h41m ago)   63d
nginx-b76bfd895-pbz7l    1/1     Running             0               6s
nginx-b76bfd895-cv7dr    1/1     Running             0               6s
nginx-b76bfd895-tt7hw    1/1     Running             0               6s
nginx-b76bfd895-v5qcl    1/1     Running             0               6s
nginx-5b7f8d685b-6f75p   1/1     Terminating         3 (27d ago)     63d
nginx-5b7f8d685b-r68kn   1/1     Terminating         3 (7h8m ago)    63d
nginx-b76bfd895-p2n9z    0/1     ContainerCreating   0               4s
nginx-b76bfd895-f44d5    1/1     Running             0               5s
nginx-b76bfd895-z88rj    0/1     Pending             0               2s
nginx-5b7f8d685b-6l82c   1/1     Terminating         3 (6h41m ago)   63d
nginx-b76bfd895-tpplt    0/1     ContainerCreating   0               3s
nginx-b76bfd895-px2bt    0/1     Pending             0               4s
nginx-b76bfd895-njq2m    1/1     Running             0               6s

 



Comments (0)
Leave a Comment