<p>We are using <em>Helm Chart</em> for deploying out application in <em>Kubernetes</em> cluster.</p>
<p>We have a statefulsets and headless service. To initialize mTLS, we have created a 'job' kind and in 'command' we are passing shell &amp; python scripts are an arguments. And created a 'cronjob' kind to update of certificate.</p>
<p>We have written a 'docker-entrypoint.sh' inside 'docker image' for some initialization work &amp; to generate TLS certificates.</p>
<p>Questions to ask :</p>
<ul>
<li>Who (Helm Chart/ Kubernetes) take care of scaling/monitoring/restarting containers ?</li>
<li>Does it deploy new docker image if pod fails/restarts ?</li>
<li>Will docker <em>ENTRYPOINT</em> execute after container fails/restarts ?</li>
<li>Does 'job' &amp; 'cronjob' execute if container restarts ?</li>
</ul>
<p>What are the other steps taken by Kubernetes ? Would you also share container insights ?</p>

Pushpendra
<p>Kubernetes and not helm will restart a failed container by default unless you set <code>restartPolicy: Never</code> in pod spec</p>
<p>Restarting of container is exactly same as starting it out first time. Hence in restart you can expect things to happen same way as it would when starting the container for first time.</p>
<p>Internally kubelet agent running in each kubernetes node delegates the task of starting a container to <a href="https://opencontainers.org" rel="nofollow noreferrer">OCI</a> complaint container runtime such as docker, containerd etc which then spins up the docker image as a container on the node.</p>
<p>I would expect entrypoint script to be executed in both start a restart of a container.</p>
<blockquote>
<p>Does it deploy new docker image if pod fails/restarts ?</p>
</blockquote>
<p>It creates a new container with same image as specified in the pod spec.</p>
<blockquote>
<p>Does 'job' &amp; 'cronjob' execute if container restarts ?</p>
</blockquote>
<p>If a container which is part of cronjob fails kubernetes will keep restarting(unless <code>restartPolicy: Never</code> in pod spec) the container till the time job is not considered as failed .Check <a href="https://stackoverflow.com/questions/51657105/how-to-ensure-kubernetes-cronjob-does-not-restart-on-failure">this</a> for how to make a cronjob not restart a container on failure. You can specify <code>backoffLimit</code> to control number of times it will retry before the job is considered failed.</p>
<p>Scaling up is equivalent of scheduling and starting yet another instance of the same container on the same or altogether different Kubernetes node.</p>
<p>As a side note you should use higher level abstraction such as deployment  instead of pod because when a pod fails Kubernetes tries to restart it on same node but when a deployment fails Kubernetes will try to restart it in other nodes as well if it's not able to start the pod on it's current scheduled node.</p>
