<p>I have a requirement of deployment in stages:</p>
<p>Stage 1</p>
<p>-Config maps and Secrets</p>
<p>Stage 2</p>
<p>-Job1</p>
<p>-Job2</p>
<p>Once Job 1 and job 2 are complete I would like to move to stage 3 which has another job</p>
<p>Stage 3</p>
<ul>
<li>Job3 ( has a readiness probe)</li>
</ul>
<p>Once stage 3 is ready I would like to move to stage 4</p>
<p>Stage 4</p>
<ul>
<li>Job 4</li>
</ul>
<p>I would like to know how this can be achieved with helm at a high level as hooks are not really waiting for the job to complete.</p>

Sourabh Ninawe
<p>Helm doesn't have this level of lifecycle control.  If &quot;job 3 (has a readiness probe)&quot; is actually a Deployment then you can almost shoehorn this into pre- and post-install hooks, but in general, this is beyond Helm's capabilities.</p>
<p>Given that you're specifically talking about run-once Jobs, I'd probably use <code>kubectl</code> to install them.  You'll need some sort of wrapper script, and then you can <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#wait" rel="nofollow noreferrer"><code>kubectl wait</code></a> for the Jobs to complete.  This might look like:</p>
<pre class="lang-sh prettyprint-override"><code># Install the configuration; since this is persistent, it makes
# sense to manage it in Helm
helm upgrade --install -n my-app my-app .

# Delete and recreate the first set of jobs, then wait for them to finish.
kubectl delete -f stage-2.yaml || true
kubectl apply -f stage-2.yaml
kubectl wait -f stage-2.yaml --for=Complete=true

# Delete and recreate the second set of jobs, _etc._
kubectl delete -f stage-3.yaml || true
kubectl apply -f stage-3.yaml
kubectl wait -f stage-3.yaml --for=Complete=true
</code></pre>
<p>If your logic is this involved, you also might consider using the <a href="https://kubernetes.io/docs/reference/using-api/" rel="nofollow noreferrer">Kubernetes API</a> to build a program to manage the Job objects.  If that program ran in the cluster, you could include its Deployment and RBAC objects in your Helm chart, and it would create the Jobs on its own.</p>
