<p>can I run a job and a deploy in a single config file/action
Where the deploy will wait for the job to finish and check if it's successful so it can continue with the deployment? </p>

Igor Igeto Mitkovski
<p>Based on the information you provided I believe you can achieve your goal using a Kubernetes feature called <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="noreferrer">InitContainer</a>:</p>

<blockquote>
  <p>Init containers are exactly like regular containers, except:</p>
  
  <ul>
  <li>Init containers always run to completion.</li>
  <li>Each init container must complete successfully before the next one starts.</li>
  </ul>
  
  <p>If a Pod’s init container fails, Kubernetes repeatedly restarts the Pod until the init container succeeds. However, if the Pod has a  <code>restartPolicy</code>  of Never, Kubernetes does not restart the Pod.</p>
</blockquote>

<ul>
<li>I'll create a <code>initContainer</code> with a <code>busybox</code> to run a command linux to wait for the service <code>mydb</code> to be running before proceeding with the deployment.</li>
</ul>

<p><strong>Steps to Reproduce:</strong>
- Create a Deployment with an <code>initContainer</code> which will run the job that needs to be completed before doing the deployment:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    run: my-app
  name: my-app
spec:
  replicas: 2
  selector:
    matchLabels:
      run: my-app
  template:
    metadata:
      labels:
        run: my-app
    spec:
      restartPolicy: Always
      containers:
      - name: myapp-container
        image: busybox:1.28
        command: ['sh', '-c', 'echo The app is running! &amp;&amp; sleep 3600']
      initContainers:
      - 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>Many kinds of commands can be used in this field, you just have to select a docker image that contains the binary you need (including your <code>sequelize</code> job)</p>

<ul>
<li>Now let's apply it see the status of the deployment:</li>
</ul>

<pre><code>$ kubectl apply -f my-app.yaml 
deployment.apps/my-app created

$ kubectl get pods
NAME                      READY   STATUS     RESTARTS   AGE
my-app-6b4fb4958f-44ds7   0/1     Init:0/1   0          4s
my-app-6b4fb4958f-s7wmr   0/1     Init:0/1   0          4s
</code></pre>

<p>The pods are hold on <code>Init:0/1</code> status waiting for the completion of the init container.
- Now let's create the service which the initcontainer is waiting to be running before completing his task:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mydb
spec:
  ports:
  - protocol: TCP
    port: 80
    targetPort: 9377
</code></pre>

<ul>
<li>We will apply it and monitor the changes in the pods:</li>
</ul>

<pre><code>$ kubectl apply -f mydb-svc.yaml 
service/mydb created

$ kubectl get pods -w
NAME                      READY   STATUS     RESTARTS   AGE
my-app-6b4fb4958f-44ds7   0/1     Init:0/1   0          91s
my-app-6b4fb4958f-s7wmr   0/1     Init:0/1   0          91s
my-app-6b4fb4958f-s7wmr   0/1     PodInitializing   0          93s
my-app-6b4fb4958f-44ds7   0/1     PodInitializing   0          94s
my-app-6b4fb4958f-s7wmr   1/1     Running           0          94s
my-app-6b4fb4958f-44ds7   1/1     Running           0          95s
^C
$ kubectl get all
NAME                          READY   STATUS    RESTARTS   AGE
pod/my-app-6b4fb4958f-44ds7   1/1     Running   0          99s
pod/my-app-6b4fb4958f-s7wmr   1/1     Running   0          99s

NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
service/mydb         ClusterIP   10.100.106.67   &lt;none&gt;        80/TCP    14s

NAME                     READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/my-app   2/2     2            2           99s

NAME                                DESIRED   CURRENT   READY   AGE
replicaset.apps/my-app-6b4fb4958f   2         2         2       99s
</code></pre>

<p>If you need help to apply this to your environment let me know.</p>
