How to extract the list of nodes which are tainted. Unable to find node name when using jsonpath as "effect:NoSchedule" or viceversa in the Kubernetes command line

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version:1.15
Cloud being used: (put bare-metal if not on a public cloud)
Installation method: kubeadm
Host OS: linux
CNI and version:
CRI and version:

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.

May be try this,

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}}’

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

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}}’

Corrected one

2 Likes