获取所有节点的污点信息
kubectl get nodes -o='custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effect'
获取集群内的所有域名
kubectl get ingress -A -o=custom-columns=Host:.spec.rules[*].host |grep -v none |sed 's/,/\n/g' |sort -n |uniq |sort |grep -v Host
获取配置了证书的域名
kubectl get ingress -A -o=custom-columns=Tls:.spec.tls[*].hosts[0] |grep -v none |sed 's/,/\n/g' |sort -n |uniq |sort |grep -v Tls
筛选运行异常的POD
kubectl get pod -A --field-selector='status.phase==Failed' --output=custom-columns=NAME:.metadata.name,NAMESPACE:.metadata.namespace,STATUS:.status.phase,AGE:'.metadata.creationTimestamp'
# 获取异常状态超过2天的POD
kubectl get pod -A --field-selector='status.phase==Failed' --output=custom-columns=NAME:.metadata.name,NAMESPACE:.metadata.namespace,STATUS:.status.phase,AGE:'.metadata.creationTimestamp'| awk '$4 <= "'$(date -d '2 days ago' -Ins --utc | sed 's/+0000/Z/')'"
标签:kubectl,get,custom,常用命令,操作,k8s,spec,columns,metadata
From: https://www.cnblogs.com/yuhaohao/p/17310007.html