<p>I have a deployment (starterservice) that deploys a single pod with a persistent volume claim. This works. However restart fails:</p>
<pre><code>kubectl rollout restart deploy starterservice
</code></pre>
<p>The new pod is started before the old one has terminated and it cannot attach the volume (Multi-Attach error for volume &quot;pvc-...&quot;). I can work around this by scaling to zero and then back up to 1 instead:</p>
<pre><code>kubectl scale --replicas=0 deployment/starterservice
kubectl scale --replicas=1 deployment/starterservice
</code></pre>
<p>I was wondering if there was a way to get <code>kubectl rollout restart</code> to wait for the old pod to terminate before starting a new one? Tx.</p>

<p>You need to set deployment strategy = recreate.</p>
<pre><code>spec:
  strategy:
    type: Recreate
</code></pre>
<p>The difference between the <code>Recreate</code> strategy compared to <code>RollingUpdate</code> (default) is that <code>Recreate</code> will terminate the old pod before creating new one while <code>RollingUpdate</code> will create new pod before terminating the old one.</p>
<p><a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#recreate-deployment" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#recreate-deployment</a></p>
