kubernetes pod creation pending

11/3/2015

I am using the fabric8.io java client for kubernetes to create and manage containers. Although when a pod is created I get the following status

{
  "kind": "Pod",
  "apiVersion": "v1",
  "metadata": {
    "name": "podName",
    "generateName": "podName-",
    "namespace": "podNameSpace",
    "selfLink": "",
    "uid": "d3d07626-825f-11e5-96f2-005056976c6f",
    "resourceVersion": "3158514",
    "creationTimestamp": "2015-11-03T19:19:39Z",
    "labels": {
      "name": ""
    },
    "annotations": {
      ""
    }
  },
  "spec": {
    "containers": [
      {
        "name": "",
        "image": "",
        "resources": {},
        "terminationMessagePath": "/dev/termination-log",
        "imagePullPolicy": "IfNotPresent"
      }
    ],
    "restartPolicy": "Always",
    "dnsPolicy": "ClusterFirst"
  },
  "status": {
    "phase": "Pending"
  }

When I try to read the logs for this pod using curl -X GET masterUrl/namespaces/namespace/pods/podName it doesnt return anything. How can I see the logs to see why the status is pending?

-- user_mda
kubernetes
kubernetes-pod
logging

1 Answer

11/3/2015

You can get events from /api/v1/events and filter for items in that list with an involvedObject which matches the Pod (e.g. same uid).

Then sort the events by most recent lastTimestamp. The reason, message, and source fields of the latest event should give you a hint about what is going on.

That's how it do it if I needed to do it from a java client.

If you just need to debug the current problem, it might be faster to just do kubectl describe pod podName, which also shows recent events for the pod.

-- Eric Tune
Source: StackOverflow