How can I list the taints on Kubernetes nodes?

前端 未结 11 1651
别那么骄傲
别那么骄傲 2021-01-30 08:47

The docs are great about explaining how to set a taint on a node, or remove one. And I can use kubectl describe node to get a verbose description of one node, inclu

11条回答
  •  粉色の甜心
    2021-01-30 09:22

    I was looking to get the list of nodes that have a specific Taint. I only found this SO answer, so if anybody is looking for this answer, here is the solution:

    kubectl get nodes -o go-template='{{range $item := .items}}{{with $nodename := $item.metadata.name}}{{range $taint := $item.spec.taints}}{{if and (eq $taint.key "node-role.kubernetes.io/master") (eq $taint.effect "NoSchedule")}}{{printf "%s\n" $nodename}}{{end}}{{end}}{{end}}{{end}}'
    

    On my cluster, the output is:

    preprod-master
    preprod-proxy
    

提交回复
热议问题