<p>I've got some strange looking behavior.</p>

<p>When a <code>job</code> is run, it completes successfully but one of the containers says it's not (or was not..) ready:</p>

<pre><code>NAMESPACE     NAME                                                 READY     STATUS      RESTARTS   AGE       IP           NODE
default       **********-migration-22-20-16-29-11-2018-xnffp       1/2       Completed   0          11h       10.4.5.8     gke-******
</code></pre>

<p>job yaml:</p>

<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: migration-${timestamp_hhmmssddmmyy}
  labels:
    jobType: database-migration
spec:
  backoffLimit: 0
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: app
        image: "${appApiImage}"
        imagePullPolicy: IfNotPresent
        command:
          - php
          - artisan
          - migrate
      - name: cloudsql-proxy
        image: gcr.io/cloudsql-docker/gce-proxy:1.11
        command: ["/cloud_sql_proxy",
                  "-instances=${SQL_INSTANCE_NAME}=tcp:3306",
                  "-credential_file=/secrets/cloudsql/credentials.json"]
        securityContext:
          runAsUser: 2  # non-root user
          allowPrivilegeEscalation: false
        volumeMounts:
          - name: cloudsql-instance-credentials
            mountPath: /secrets/cloudsql
            readOnly: true
      volumes:
        - name: cloudsql-instance-credentials
          secret:
            secretName: cloudsql-instance-credentials
</code></pre>

<p>What may be the cause of this behavior? There is no readiness or liveness probes defined on the containers.</p>

<p>If I do a describe on the pod, the relevant info is:</p>

<pre><code>...
Command:
  php
  artisan
  migrate
State:          Terminated
  Reason:       Completed
  Exit Code:    0
  Started:      Thu, 29 Nov 2018 22:20:18 +0000
  Finished:     Thu, 29 Nov 2018 22:20:19 +0000
Ready:          False
Restart Count:  0
Requests:
  cpu:  100m
...
</code></pre>

<p>A Pod with a <code>Ready</code> status means it <em>"is able to serve requests and should be added to the load balancing pools of all matching Services"</em>, see <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions" rel="noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions</a></p>

<p>In your case, you don't want to serve requests, but simply to execute <code>php artisan migrate</code> once, and done. So you don't have to worry about this status, the important part is the <code>State: Terminated</code> with a <code>Reason: Completed</code> and a zero exit code: your command did whatever and then exited successfully.</p>

<p>If the result of the command is not what you expected, you'd have to investigate the logs from the container that ran this command with <code>kubectl logs your-pod -c app</code> (where <code>app</code> is the name of the container you defined), and/or you would expect the <code>php artisan migrate</code> command to NOT issue a zero exit code.</p>
