kubectl get
command has this flag -o
to format the output.
Is there a similar way to format the output of the kubectl describe
command?
For example:
kubectl describe -o="jsonpath={...}" pods my-rc
would print a JSON format for the list of pods in my-rc
replication controller. But -o
is not accepted for the describe
command.
kubectl describe
doesn't support-o
or equivalent. It's meant to be human-readable rather than script-friendly. You can achieve what you described withkubectl get pods -l <selector_of_your_rc> -o <output_format>
, for example:In my case, I needed to get the load balancer address from the service. I did it using
kubectl get service
:As @janekuto suggested
Please see my answer here. jq is really a powerful utility to play around with json display of kubectl. You can do so much with jq without putting too much efforts.
kubectl - format the resource quota values in json format
Based on the output of
kubectl help describe
, it looks like it does not support structured output: