|NO.Z.00021|——————————|^^ 標準 ^^|——|KuberNetes&標準.V20|---------------------------------------------------------|常用操作.V06|格式化輸出|
阿新 • • 發佈:2022-03-29
[CloudNative:KuberNetes&書籤.V20] [Applications.KuberNetes] [|DevOps|kubernetes|k8s.二進位制1.20|網路規劃|常用操作|]
一、格式化輸出:以特定格式將詳細資訊輸出到終端視窗可以將
-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.*'
===============================END===============================
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
來自為知筆記(Wiz)