How to restart Kubernetes deployment with persistent volume claims?

Viewed 674

I have a deployment (starterservice) that deploys a single pod with a persistent volume claim. This works. However restart fails:

kubectl rollout restart deploy starterservice

The new pod is started before the old one has terminated and it cannot attach the volume (Multi-Attach error for volume "pvc-..."). I can work around this by scaling to zero and then back up to 1 instead:

kubectl scale --replicas=0 deployment/starterservice
kubectl scale --replicas=1 deployment/starterservice

I was wondering if there was a way to get kubectl rollout restart to wait for the old pod to terminate before starting a new one? Tx.

1 Answers
Related