# Restart all deployment in a namespace

**URL:** <https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165>\
**Category:** General Discussions\
**Created:** [September 30, 2019, 8:36am UTC](https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165 "2019-09-30T08:36:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dinesh3467](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@Dinesh3467](https://discuss.kubernetes.io/u/Dinesh3467)\
**Post date:** [September 30, 2019, 8:36am UTC](https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165/1 "2019-09-30T08:36:23Z")

</div>

Hi All, Is there a way I can restart all the deployments in a particular namespace.  
For example, I am using istio in my EKS cluster, once the upgrade happens I have to restart all the deployments in my application namespace to start use the new sidecars. They gave command like below but it is not working.

kubectl rollout restart deployment --namespace apps

But when I use this command, I get the below error. Is there a way I can do a rolling restart of my deployments.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/kubernetes/original/2X/e/e40a4ab978027f32b1c3dee7baac0dc9149309c6.jpeg)

---

<div class="post-metadata">

**Author:** ![jaypipes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jaypipes/32/1443_2.png) [@jaypipes](https://discuss.kubernetes.io/u/jaypipes)\
**Post date:** [September 30, 2019, 12:02pm UTC](https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165/2 "2019-09-30T12:02:41Z")

</div>

You need to specify which deployment to restart:

kubectl rollout restart deployments/isam-config-deploy -n apps  
kubectl rollout restart deployments/isam-config-deploy-test -n apps

Note that the pods in your deployment will be terminated and then re-  
created.

Best,  
-jay

---

<div class="post-metadata">

**Author:** ![Dinesh3467](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@Dinesh3467](https://discuss.kubernetes.io/u/Dinesh3467)\
**Post date:** [September 30, 2019, 12:33pm UTC](https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165/3 "2019-09-30T12:33:00Z")

</div>

Thanks Jay for the response. Is there a way to restart all the deployments in a particular namespace with single command in rolling fashion

---

<div class="post-metadata">

**Author:** ![jaypipes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jaypipes/32/1443_2.png) [@jaypipes](https://discuss.kubernetes.io/u/jaypipes)\
**Post date:** [September 30, 2019, 1:43pm UTC](https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165/4 "2019-09-30T13:43:00Z")

</div>

Not that I’m aware of. You’d want to do something like this:

```bash
deploys=`kubectl get deployments -n apps | tail -n1 | cut -d ' ' -f 1`
for deploy in $deploys; do
  kubectl rollout restart deployments/$deploy -n apps
done

```

Best,  
-jay

---

<div class="post-metadata">

**Author:** ![Dinesh3467](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@Dinesh3467](https://discuss.kubernetes.io/u/Dinesh3467)\
**Post date:** [October 1, 2019, 2:37am UTC](https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165/5 "2019-10-01T02:37:12Z")

</div>

Hi Jay, I tried even with the deployment name but still the same error.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/kubernetes/original/2X/a/a4c9eb106809331b2fc09e09dcf6b19425427fd9.png)

---

<div class="post-metadata">

**Author:** ![jaypipes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jaypipes/32/1443_2.png) [@jaypipes](https://discuss.kubernetes.io/u/jaypipes)\
**Post date:** [October 1, 2019, 12:08pm UTC](https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165/6 "2019-10-01T12:08:17Z")

</div>

What version of k8s are you using? I’m using 1.15.3 and the commands I  
listed work properly. You can see the pods in the nginx deployment get  
terminated and recreated when I run kubectl rollout restart here:

```auto
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-deployment-57f8b7cdfb-54s4b 1/1 Running 0 22h
nginx-deployment-57f8b7cdfb-5b5dd 1/1 Running 0 22h
$ deploys=`kubectl get deployments | tail -n1 | cut -d ' ' -f 1`
$ for deploy in $deploys; do kubectl rollout restart
deployments/$deploy; done
deployment.extensions/nginx-deployment restarted
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-deployment-75cfbd6cf5-nvqhc 1/1 Running 0 20s
nginx-deployment-75cfbd6cf5-tdfw2 1/1 Running 0 21s

```

Note that I don’t have an “apps” namespace, so I left off “-n apps” to  
use the default namespace. Other than that, it’s the exact commands I’d  
listed.

Best,  
-jay

---

<div class="post-metadata">

**Author:** ![Dinesh3467](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@Dinesh3467](https://discuss.kubernetes.io/u/Dinesh3467)\
**Post date:** [October 1, 2019, 1:07pm UTC](https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165/7 "2019-10-01T13:07:09Z")

</div>

Thanks Jay, that was exactly the issue I was facing. My kubectl version was 1.14, I got to know that this restart feature was added from 1.15. It is working fine now, even the below command is working that I am able to restart the deployment using single command

Kubectl rollout restart deployment -n apps

But want to check with you one thing, we are using AWS EKS, which has Kubernetes version 1.14, can we use a kubectl client of higher version to take to eks api of 1.14?

Thanks again for fixing my issue 🙂

---

<div class="post-metadata">

**Author:** ![Bernhard\_Fuchs](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/bernhard_fuchs/32/6702_2.png) [@Bernhard\_Fuchs](https://discuss.kubernetes.io/u/Bernhard_Fuchs)\
**Post date:** [February 8, 2021, 1:02pm UTC](https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165/8 "2021-02-08T13:02:37Z")

</div>

`kc rollout restart deploy`  
That’s all you need. See [https://qvault.io/2020/10/26/how-to-restart-all-pods-in-a-kubernetes-namespace/](https://qvault.io/2020/10/26/how-to-restart-all-pods-in-a-kubernetes-namespace/) also for a working bash script if needed for backwards compatibility.

---

<div class="post-metadata">

**Author:** ![shoebhasan](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@shoebhasan](https://discuss.kubernetes.io/u/shoebhasan)\
**Post date:** [September 27, 2021, 3:52pm UTC](https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165/9 "2021-09-27T15:52:46Z")

</div>

rollout restart will not terminate pods first and then recreate new pods. That scenario will happen if you delete any pod.  
Instead, rollout restart will create new pods first then terminate old pods assuring your new pods are ready to serve.

---

<div class="post-metadata">

**Author:** ![shoebhasan](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@shoebhasan](https://discuss.kubernetes.io/u/shoebhasan)\
**Post date:** [September 27, 2021, 4:37pm UTC](https://discuss.kubernetes.io/t/restart-all-deployment-in-a-namespace/8165/10 "2021-09-27T16:37:28Z")

</div>

Command to restart all deployments:  
kubectl rollout restart deployment -n

I am using version 1.18.
