When I try to create Deployment as Type Job, it's not pulling any image.
Below is .yaml:
apiVersion: batch/v1 kind: Job metadata: name: copyartifacts spec: backoffLimit: 1 template: metadata: name: copyartifacts spec: restartPolicy: "Never" volumes: - name: sharedvolume persistentVolumeClaim: claimName: shared-pvc - name: dockersocket hostPath: path: /var/run/docker.sock containers: - name: copyartifacts image: alpine:3.7 imagePullPolicy: Always command: ["sh", "-c", "ls -l /shared; rm -rf /shared/*; ls -l /shared; while [ ! -d /shared/artifacts ]; do echo Waiting for artifacts to be copied; sleep 2; done; sleep 10; ls -l /shared/artifacts; "] volumeMounts: - mountPath: /shared name: sharedvolume
Can you please guide here?
Regards, Vikas
There could be two possible reasons for not seeing pod.
1. Pod hasn't been created:
If pod hasn't been created yet, you have to find out why the job failed to create pod. You can view job's events to see if there are any failure event. Use following command to describe a job.
kubectl describe job <job-name> -n <namespace>
Then, check the Events:
field. There might be some events showing pod creation failure with respective reason.
2. Pod has completed and terminated:
Job's are used to perform one-time task rather than serving an application that require to maintain a desired state. When the task is complete, pod goes to completed state then terminate (but not deleted). If your Job is intended for a task that does not take much time, the pod may terminate after completing the task before you have noticed.
As the pod is terminated, kubectl get pods
will not show that pod. However, you will able to see the pod using kubectl get pods -a
command as it hasn't been deleted.
You can also describe the job and check for completion or success event.