I am trying to get the pod name with highest CPU utilization using kubectl command. Able to retrieve list using following command but unable to write a jsonpath query to fetch the name of first pod from the output. Appreciate any help in this regard. Thanks!
kubectl top pod POD_NAME --sort-by=cpu
kubectl top
doesn't appear to enable --output
formatting and so no JSON and thus no JSONPath :-(
You can:
kubectl top pod \
--sort-by=cpu \
--no-headers \
--namespace=${NAMESPACE} \
| head -n 1
I think it would be useful to support --output
for all kubectl
commands and you may wish to submit a feature request for this.
NOTE Hmmm
kubectl top
output format options