<p>I am struggling to understand how to deal with the following scenario in Kubernetes.</p>
<p>I have an application with a daemon (not a daemon set)</p>
<ol>
<li>There should be only one instance of it at a time.</li>
<li>PVC should be mounted to the active POD exclusively</li>
<li>Downtimes are <strong>acceptable</strong> (obviously)</li>
</ol>
<p>In order to make this happen I have to set replicas to 0 (in the deployment) in order to get rid of the running pods, then roll out an update. Otherwise, Kubernetes just mounts the pod in the second replica and the application keeps crashing because only one instance of it can access PVC in write mode. I cannot allow ReadWriteMany and I cannot tolerate those rolling updates where 2 versions are running.</p>
<p>I read up on Stateful Sets, but that doesn't seem to work, since k8s will create a new PVC storage, which I want to avoid.</p>
<p>What's the most elegant solution to this problem? (besides setting replica to 0)</p>
<p>Thanks</p>

user3677173
<p>The solution turned out to be very simple:</p>
<p><code>.spec.strategy.type==Recreate</code></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>
