<p>I am using Kubernetes with Helm 3.</p>
<p>It is ran on CentOS Linux 7 (Core).</p>
<p>K8S (check by running: kubectl version):</p>
<p>git version (kubernetes): v1.21.6, go version: go1.16.9.</p>
<p>helm version: v3.3.4</p>
<p>helm version (git) go1.14.9.</p>
<p>I need to create a Job that is running after a Pod is created.</p>
<p>The pod yaml:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: {{ include &quot;test.fullname&quot; . }}-mysql
  labels:
    app: {{ include &quot;test.fullname&quot; . }}-mysql
  annotations:
    &quot;helm.sh/hook&quot;: post-install
    &quot;helm.sh/hook-weight&quot;: &quot;-20&quot;
    &quot;helm.sh/delete-policy&quot;: before-hook-creation
spec:
  containers:
    - name: {{ include &quot;test.fullname&quot; . }}-mysql
      image: {{ .Values.mysql.image }}
      imagePullPolicy: IfNotPresent
      env:
        - name: MYSQL_ROOT_PASSWORD
          value: &quot;12345&quot;
        - name: MYSQL_DATABASE
          value: test
</code></pre>
<p>The Job:</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: {{ include &quot;test.fullname&quot; . }}-migration-job
  labels:
    app: {{ include &quot;test.fullname&quot; . }}-migration-job
  annotations:
    &quot;helm.sh/hook&quot;: post-install
    &quot;helm.sh/hook-weight&quot;: &quot;-10&quot;
    &quot;helm.sh/hook-delete-policy&quot;: hook-succeeded, hook-failed
spec:
  parallelism: 1
  completions: 1
  backoffLimit: 1
  template: #PodTemplateSpec (Core/V1)
    spec: #PodSpec (core/v1)
    initContainers: # regular
    - name: wait-mysql
      image: bitnami/kubectl
      imagePullPolicy: IfNotPresent
      args:
        - wait
        - pod/{{ include &quot;test.fullname&quot; . }}-mysql
        - --namespace={{ .Release.Namespace }}
        - --for=condition=ready
        - --timeout=120s
    containers:
      - name: {{ include &quot;test.fullname&quot; . }}
        image: {{ .Values.myMigration.image }}
        imagePullPolicy: IfNotPresent
        command: {{- toYaml .Values.image.entrypoint | nindent 12 }}
        args: {{- toYaml .Values.image.cmd | nindent 12}}
</code></pre>
<p>MySQL is MySQL 5.6 image.</p>
<p>When I write the above, also run <code>helm install test ./test --namespace test --create-namespace</code></p>
<p>Even though I changed the hook for pre-install (for Pod and Job), the job is never running.</p>
<p>In both situations, I get messages (and need to press - to exit - I don't want this behavior either:</p>
<blockquote>
<p>Pod test-mysql pending Pod test-mysql pending Pod</p>
</blockquote>
<blockquote>
<p>test-mysql pending Pod test-mysql running Pod</p>
</blockquote>
<blockquote>
<p>test-mysql running Pod test-mysql running Pod</p>
</blockquote>
<blockquote>
<p>test-mysql running ...</p>
</blockquote>
<p>In this example, when I put a 'bug' in the Job, for example: <code>containersx</code> instead of <code>container</code>, I don't get any notification that I have a wrong syntax.</p>
<p>Maybe because MySQL is running (and not completed), can I force to go to the next yaml declared by hook? (Even I declare the proper order for Pod and Job. Pod should run before Job).</p>
<p>What is wrong, and how can I ensure the pod is created before the job? And when the pod starts running, my job will run after that?</p>
<p>Thanks.</p>

Eitan
<p>As per your configuration, it looks like you need to set <code>post-install</code>  <a href="https://helm.sh/docs/topics/charts_hooks/#the-available-hooks" rel="nofollow noreferrer">hook</a> precisely for Job as it should execute after all resources are loaded into Kubernetes. On executing  <code>pre-install</code> hook both on Pod and Job, it is run before the rest of the chart is loaded, which seems to prevent Job from starting.</p>
