|NO.Z.00021|——————————|^^ 标准 ^^|——|KuberNetes&标准.V20|——|常用操作.V06|格式化输出|
一、格式化输出:以特定格式将详细信息输出到终端窗口可以将
-o或--output参数添加到支持的kubectl命令|
输出格式 |
描述 |
|
|
使用逗号分隔的自定义列来打印表格 |
|
|
使用 |
|
|
输出 JSON 格式的 API 对象 |
|
|
打印 jsonpath 表达式中定义的字段 |
|
|
打印在 |
|
|
仅打印资源名称而不打印其他内容 |
|
|
以纯文本格式输出额外信息,对于 Pod 来说输出中包含了节点名称 |
|
|
输出 YAML 格式的 API 对象 |
二、使用 -o=custom-columns 的示例:
### --- 使用 -o=custom-columns 的示例:
~~~ # 集群中运行着的所有镜像
[root@k8s-master01 ~]# kubectl get pods -A -o=custom-columns='DATA:spec.containers[*].image'
~~~ # 除 "k8s.gcr.io/coredns:1.6.2" 之外的所有镜像
[root@k8s-master01 ~]# kubectl get pods -A -o=custom-columns='DATA:spec.containers[?(@.image!="k8s.gcr.io/coredns:1.6.2")].image'
~~~ # 输出 metadata 下面的所有字段,无论 Pod 名字为何
[root@k8s-master01 ~]# kubectl get pods -A -o=custom-columns='DATA:metadata.*'
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
浙公网安备 33010602011771号