跳到主要内容

Node 相关

表格输出节点 IP 相关属性

kubectl get no -o=custom-columns=NAME:.metadata.name,INTERNAL-IP:.status.addresses[0].address,EXTERNAL-IP:.status.addresses[1].address,CIDR:.spec.podCIDR

表格输出各节点总可用资源 (Allocatable)

kubectl get no -o=custom-columns="NODE:.metadata.name,ALLOCATABLE CPU:.status.allocatable.cpu,ALLOCATABLE MEMORY:.status.allocatable.memory"

输出各节点已分配资源的情况

所有种类的资源已分配情况概览

kubectl get nodes --no-headers | awk '{print $1}' | xargs -I {} sh -c "echo {} ; kubectl describe node {} | grep Allocated -A 5 | grep -ve Event -ve Allocated -ve percent -ve --;"

表格输出 cpu 已分配情况

kubectl get nodes --no-headers | grep -v eklet- | awk '{print $1}' | xargs -I {} sh -c 'node="{}"; cpu=$(kubectl describe node "$node" | grep "Allocated resources:" -A5 | grep -ve Event -ve Allocated -ve percent -ve -- | grep cpu | awk '\''{print $2$3}'\''); printf "%s\t%s\n" "$node" "$cpu"'

表格输出 memory 已分配情况

kubectl get nodes --no-headers | grep -v eklet- | awk '{print $1}' | xargs -I {} sh -c 'node="{}"; memory=$(kubectl describe node "$node" | grep "Allocated resources:" -A6 | grep -ve Event -ve Allocated -ve percent -ve -- | grep memory | awk '\''{print $2$3}'\''); printf "%s\t%s\n" "$node" "$memory"'

表格输出节点可用区分布情况

kubectl get node -o custom-columns=NAME:.metadata.name,ZONE:".metadata.labels.topology\.kubernetes\.io/zone"