<p>I am looking for a Kubectl wait command for init containers. Basically I need to wait until pod initialization of init container before proceeding for next step in my script. </p>

<p>I can see a wait option for pods but not specific to init containers.</p>

<p>Any clue how to achieve this</p>

<p>Please suggest any alternative ways to wait in script</p>

magic
<p>You can run multiple commands in the init container or multiple init containers to do the trick.</p>

<p><br></p>

<ul>
<li>Multiple commands</li>
</ul>

<pre><code>command: ["/bin/sh","-c"]
args: ["command one; command two &amp;&amp; command three"]
</code></pre>

<p>Refer: <a href="https://stackoverflow.com/a/33888424/3514300">https://stackoverflow.com/a/33888424/3514300</a></p>

<p><br>
* Multiple init containers</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  containers:
  - name: myapp-container
    image: busybox:1.28
    command: ['sh', '-c', 'echo The app is running! &amp;&amp; sleep 3600']
  initContainers:
  - name: init-myservice
    image: busybox:1.28
    command: ['sh', '-c', "until nslookup myservice.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for myservice; sleep 2; done"]
  - name: init-mydb
    image: busybox:1.28
    command: ['sh', '-c', "until nslookup mydb.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for mydb; sleep 2; done"]
</code></pre>

<p>Refer: <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#init-containers-in-use" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#init-containers-in-use</a></p>
