<p><strong>Usecase</strong></p>
<p>I am running a statefulset (a database) with 3 pods. One of these pods is constantly crashing (CrashLoopBackoff state) because there are some corrupted files in the attached persistent volume which I need to delete. However I can't exec into this pod as it's constantly crashing right after it has detected these corrupted files.</p>
<p>I'm aware that I can use something like this command to prevent the restarts <code>['sh', '-c', 'echo The app is running! &amp;&amp; sleep 36000']</code> however I can't edit my statefulset as this would cause a rolling update then.</p>
<p><strong>Question</strong></p>
<p>How can I exec into a constantly crashing pod in a statefulset without affecting the other running pods?</p>

<p>There is no easy way to modify a single specific pod as part of the statefulset without affecting all the other pods of the statefulset. If a single pod is stuck in the CrashLoopBackoff the restart time will periodically increase.</p>
<p>Since the goal was to modify some files on the attached persistent volume we can simply start a whole different pod that attaches to the persistent volume. Because only one pod can be attached to the same Persistent volume at the same time we can now modify all files and once the pod is shutdown again the PVC is available for use by the pod in the statefulset.</p>
<p>Another idea is temporarily modifying the statefulset and adding pre stop hooks where we sleep for some time, so that you have a chance to exec into the pod before it's actually killed.</p>
