<p>On an occasional basis I need to perform a rolling replace of all Pods in my StatefulSet such that all PVs are also recreated from scratch. The reason to do so is to get rid of all underlying hard drives that use old versions of encryption key. This operation should not be confused with regular rolling upgrades, for which I still want volumes to survive Pod terminations. The best routine I figured so far to do that is following:</p>

<ol>
<li>Delete the PV.</li>
<li>Delete the PVC.</li>
<li>Delete the Pod.</li>
<li>Wait until all deletions complete.</li>
<li>Manually recreate the PVC deleted in step 2.</li>
<li>Wait for the new Pod to finish streaming data from other Pods in the StatefulSet.</li>
<li>Repeat from step 1. for the next Pod.</li>
</ol>

<p>I'm not happy about step 5. I wish StatefulSet recreated the PVC for me, but unfortunately it does not. I have to do it myself, otherwise Pod creation fails with following error: </p>

<pre><code>Warning  FailedScheduling   3s (x15 over 15m)  default-scheduler   persistentvolumeclaim "foo-bar-0" not found
</code></pre>

<p>Is there a better way to do that?</p>

lopek
<p>I just recently had to do this. The following worked for me:</p>
<pre><code># Delete the PVC
$ kubectl delete pvc &lt;pvc_name&gt;

# Delete the underlying statefulset WITHOUT deleting the pods
$ kubectl delete statefulset &lt;statefulset_name&gt; --cascade=false 

# Delete the pod with the PVC you don't want
$ kubectl delete pod &lt;pod_name&gt;

# Apply the statefulset manifest to re-create the StatefulSet, 
# which will also recreate the deleted pod with a new PVC
$ kubectl apply -f &lt;statefulset_yaml&gt;

</code></pre>
