Vikas Banage
Vikas Banage

Reputation: 514

Not able to see Pod when I create a Job

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

Upvotes: 1

Views: 7435

Answers (2)

jordon
jordon

Reputation: 1

if you use kind created the K8s cluster, all the cluster node run as docker. If you had reboot you computer or VM, the cluster (pod) ip address may change, leeding to the cluster node internet communication failed. In this case, see the cluster manager logs, it has error message. Job created, but pod not.

try to re-create the cluster, or change the node config about ip address.

Upvotes: 0

Emruz Hossain
Emruz Hossain

Reputation: 5528

There could be two possible reasons for not seeing pod.

  1. The pod hasn't been created yet.
  2. The pod has completed it's task and terminated before you have noticed.

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.

Upvotes: 6

Related Questions