I have a deployment (starterservice) that deploys a single pod with a persistent volume claim. This works. However restart fails:
kubectl rollout restart deploy starterserviceThe 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/starterserviceI 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.
You need to set deployment strategy = recreate.
spec:
strategy:
type: RecreateThe difference between the Recreate strategy compared to RollingUpdate (default) is that Recreate will terminate the old pod before creating new one while RollingUpdate will create new pod before terminating the old one.
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#recreate-deployment