What is the jsonpath for Kubernetes POD status?

9/6/2017

I couldn't find the status jsonpath when using kubectl. The pod json has a status field but it is an array.

kubectl get pods --column=Status:.status[*]

There are several elements in the array, how can I select the one for real pod status?

-- reachlin
jsonpath
kubectl
kubernetes

1 Answer

9/7/2017
  1. One must enable jsonpath output, via kubectl get pods --output="jsonpath={.status}", not via --column
  2. The results were an array because as written kubectl is returning all Pods that are in the current namespace. To get a singular Pod status, qualify your request with:
    kubectl get pod $the_pod_name_here --output="jsonpath={.status}"
    if you really do want the status of all pods, then --output="jsonpath={.items[*].status}" is likely the syntax you were seeking
-- mdaniel
Source: StackOverflow