<p>I'm trying to build an application that stores the specs of certain Kubernetes resources in a variable.</p>
<p>It then sleeps for a pre-defined time like 7 days, then the application runs again, and compares the specs of the same resources <strong>now</strong> to the specs <strong>previously stored</strong> in a variable.</p>
<p>The problems are:</p>
<ol>
<li><p>If the application pod restarts for any reason, like a node rotation, it will lose its stored specs and won't be able to compare them.</p>
</li>
<li><p>How to make sure that the application will return to the exact point it was when it died? For example, what if the application's pod dies right during the <strong>sleep</strong> function?</p>
</li>
</ol>
<p>I've heard that <code>StatefulSet</code> is the answer, but does it guarantee problem number 2 doesn't happen?</p>

Kaio H. Cunha
<p>Pods that store durable data should make use of <a href="https://kubernetes.io/docs/concepts/storage/volumes/" rel="nofollow noreferrer">Volumes</a>. If each Pod needs its own volume than StatefulSets are the right choice, since K8s will take care of reattaching Pods to their volumes after restarts.</p>
<p>Pods in K8s will not natively resume where they left off, since a Pod restart triggers the termination of the original application process(es). There is no support for pausing processes. So, you would need to take care of that kind of behavior in your application code.</p>
