kubectl 獲取資源信息時有默認的資源信息列,除此之外kubectl也支持自定義資源信息列.
example
獲取自定義的deployment信息,自定義 namespace,name
,replicas,nodeSelector.
kubectl get deployment -o custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,REPLICAS:.spec.replicas,NODE-SELECTOR:.spec.template.spec.nodeSelector --all-namespaces=true >/tmp/deploy-all.txt
上面通過參數(shù)-o custom-columns定義了自動輸出的列,自定義了列頭和輸出內(nèi)容.