How can I list taints on my nodes?

The docs are good for explaining how to fix harm on a host or remove it. And I can use kubectl describe nodeto get a detailed description of one node, including its shortcomings. But what if I forgot the name of the created mucose or which nodes I installed? Can I list all my nodes with any harmful effects on them?

+22
source share
6 answers
kubectl get nodes -o json | jq '.items[].spec'

which will give the full specification with the name of the node, or:

kubectl get nodes -o json | jq '.items[].spec.taints'

will produce a harm list for each node

+26
source

Kubernetes 1.6.x . jaxxstorm . .

{{printf "%-50s %-12s\n" "Node" "Taint"}}
{{- range .items}}
    {{- if $taint := (index .spec "taints") }}
        {{- .metadata.name }}{{ "\t" }}
        {{- range $taint }}
            {{- .key }}={{ .value }}:{{ .effect }}{{ "\t" }}
        {{- end }}
        {{- "\n" }}
    {{- end}}
{{- end}}

, :

kubectl get nodes -o go-template-file="./nodes-taints.tmpl"

:

Node                                            Taint
ip-xxx-xxx-xxx-xxx.us-west-2.compute.internal   dedicate=etcd:NoSchedule
ip-xxx-xxx-xxx-xxx.us-west-2.compute.internal   dedicate=jenkins:NoSchedule
ip-xxx-xxx-xxx-xxx.us-west-2.compute.internal   dedicate=etcd:NoSchedule
ip-xxx-xxx-xxx-xxx.us-west-2.compute.internal   dedicate=containerlinux-canary-channel-workers:NoSchedule
ip-xxx-xxx-xxx-xxx.us-west-2.compute.internal   dedicate=jenkins:NoSchedule
ip-xxx-xxx-xxx-xxx.us-west-2.compute.internal   dedicate=etcd:NoSchedule
ip-xxx-xxx-xxx-xxx.us-west-2.compute.internal   dedicate=etcd:NoSchedule
ip-xxx-xxx-xxx-xxx.us-west-2.compute.internal   dedicate=etcd:NoSchedule
ip-xxx-xxx-xxx-xxx.us-west-2.compute.internal   dedicate=jenkins:NoSchedule

go, , -, , .


, , :

kubectl get nodes -o go-template='{{printf "%-50s %-12s\n" "Node" "Taint"}}{{- range .items}}{{- if $taint := (index .spec "taints") }}{{- .metadata.name }}{{ "\t" }}{{- range $taint }}{{- .key }}={{ .value }}:{{ .effect }}{{ "\t" }}{{- end }}{{- "\n" }}{{- end}}{{- end}}'
+28

taints node, :

kubectl describe nodes your-node-name

:

Name:                   your-node-name
...
Taints:                 node-role.kubernetes.io/master:NoSchedule
CreationTimestamp:      Wed, 19 Jul 2017 06:00:23 +0800
+15

kubectl kubectl go-template, ,

kubectl get nodes -o go-template='{{range.items}}{{if $x := index.metadata.annotations "scheduler.alpha.kubernetes.io/taints"}}{{with $x := index.metadata.name}}{{.}}{{printf "\n"}}{{end}}{{end}}{{end}}'

, :

kubemaster-1.example.net
kubemaster-2.example.net
kubemaster-3.example.net
+2

I was looking for a list of nodes that have a specific taint. I found only this SO answer, so if someone 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
+2
source

PowerShell: \> kubectl describe nodes | findstr "Taint Hostname"

or

Bash # kubectl describe nodes | egrep "Taint | Hostname"

This command is insanely easy to remember.

The output looks like this:

Taints:             <none>  
  Hostname:   aks-agentpool-30208295-0  
Taints:             <none>    
  Hostname:  aks-agentpool-30208295-1
...
0
source

Source: https://habr.com/ru/post/1674699/


All Articles