kkpareek
kkpareek

Reputation: 540

Why does pod status remain 'PENDING'?

Here is the output I am getting:

    [root@ip-10-0-3-103 ec2-user]# kubectl get pod --namespace=migration
    NAME                                          READY   STATUS    RESTARTS   AGE
    clear-nginx-deployment-cc77649fb-j8mzj        0/1     Pending   0          118m
    clear-nginx-deployment-temp-cc77649fb-hxst2   0/1     Pending   0          41s

Could not understand the message shown in json:

*"status": 
{
        "conditions": [
            {
                "message": "0/1 nodes are available: 1 pod has unbound immediate PersistentVolumeClaims.",

                "reason": "Unschedulable",
                "status": "False",
                "type": "PodScheduled"
            }
        ],
        "phase": "Pending",
        "qosClass": "BestEffort"
}*

If you could please help to get through this. The earlier question on stackoverflow doesn't answer my query as my message output is different.

Upvotes: 1

Views: 848

Answers (1)

F1ko
F1ko

Reputation: 4284

This is due to the fact that your Pods have been instructed to claim storage, however, in your case there is storage available. Check your Pods with kubectl get pods <pod-name> -o yaml and look at the exact yaml that has been applied to the cluster. In there you should be able to see that the Pod is trying to claim a PersistentVolume (PV).

To quickly create a PV backed by a hostPath apply the following yaml:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: stackoverflow-hostpath
  namespace: migration
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  hostPath:
    path: "/mnt/data"

Kubernetes will exponentially try to schedule the Pod again; to speed things up delete one of your pods (kubectl delete pods <pod-name>) to reschedule it immediately.

Upvotes: 3

Related Questions