What is the jsonpath for Kubernetes POD status?

13k views Asked by At

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?

1

There are 1 answers

0
mdaniel On
  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