<p>As per <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#understanding-init-containers" rel="nofollow noreferrer">this link</a>, all init containers always run to completion. And init container must complete successfully before the next one starts.</p>
<p>In my case, there is a case where i want to keep a process running throughout pod lifecycle, quite similar to the way <a href="https://kubernetes.io/docs/concepts/storage/volumes/#emptydir" rel="nofollow noreferrer">emptyDir</a> are preserved throughout pod lifecycle.</p>
<p>I did all my research but couldn't find a way. Are there are workaround to achieve the goal?</p>

codeofnode
<p>Use of <code>shareProcessNamespace: true</code> helps in such case. We just need to start a child process in background via init container.</p>
<p>Here is an example</p>
<pre><code>---
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: demo
  name: demo
spec:
  shareProcessNamespace: true
  initContainers:
    - name: iapp
      image: nicolaka/netshoot:latest
      command:
        - &quot;bash&quot;
      args:
        - &quot;-c&quot;
        - &quot;tail -f /dev/null &amp; echo iapp&quot;
  containers:
    - name: app
      image: nicolaka/netshoot:latest
      command:
        - &quot;sleep&quot;
      args:
        - &quot;inifinity&quot;
</code></pre>
<p>After pod is running, when we exec into <code>app</code> container, and do <code>ps aux</code>. We can see <code>tail -f /dev/null</code> still there. Which confirms that we can have a process running throughout pod lifecycle.</p>
