问题描述
kubectl get
命令具有此标志-o
来格式化输出.
kubectl get
command has this flag -o
to format the output.
是否有类似的方式来格式化kubectl describe
命令的输出?
Is there a similar way to format the output of the kubectl describe
command?
例如:
kubectl describe -o="jsonpath={...}" pods my-rc
将为my-rc
复制控制器中的Pod列表打印JSON格式.但是describe
命令不接受-o
.
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
不支持-o
或等效版本.它应该是人类可读的,而不是脚本友好的.您可以使用kubectl get pods -l <selector_of_your_rc> -o <output_format>
实现您所描述的内容,例如:
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 with kubectl get pods -l <selector_of_your_rc> -o <output_format>
, for example:
$ kubectl get pods -l app=guestbook,tier=frontend -o name
pod/frontend-a4kjz
pod/frontend-am1ua
pod/frontend-yz2dq
这篇关于如何将kubectl描述的输出格式化为JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!