How can I list the taints on Kubernetes nodes?
How can I list the taints on Kubernetes nodes?
https://stackoverflow.com/questions/43379415/how-can-i-list-the-taints-on-kubernetes-nodes
Asked 8 years, 9 months ago Modified 1 year, 8 months ago Viewed 169k times 126
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, including its taints. But what if I’ve forgotten the name of the taint I created, or which nodes I set it on? Can I list all of my nodes, with any taints that exist on them?
kubernetes Share Improve this question Follow edited Apr 30, 2020 at 1:28 Old Pro’s user avatar Old Pro 25.8k88 gold badges6565 silver badges116116 bronze badges asked Apr 12, 2017 at 20:50 Chris Jones’s user avatar Chris Jones 5,41466 gold badges3838 silver badges2929 bronze badges Add a comment 15 Answers Sorted by:
Highest score (default) 147
kubectl get nodes -o json | jq ‘.items[].spec’ which will give the complete spec with node name, or:
kubectl get nodes -o json | jq ‘.items[].spec.taints’ will produce the list of the taints per each node
Share Improve this answer Follow edited Oct 10, 2019 at 11:20 German Lashevich’s user avatar German Lashevich 2,54411 gold badge3232 silver badges4141 bronze badges answered Dec 17, 2018 at 21:00 kranthi guttikonda’s user avatar kranthi guttikonda 1,59411 gold badge1010 silver badges33 bronze badges Sign up to request clarification or add additional context in comments.
4 Comments
lights Over a year ago or if you want the ip-xx.internal node name you can do: kubectl get nodes -o json | jq “.items[]|{name:.metadata.name, taints:.spec.taints}”
Lukasz Dynowski Over a year ago this answer base on assumes that jq is installed.
Snowcrash Over a year ago And also just outputs a bunch of taints without outputting the name of the node they’re associated with which isn’t much use.
Hem Jul 24, 2025 at 11:16 Short answer from @Tim with kubectl command kubectl get nodes -o=custom-column -o=custom-columns=Name:.metadata.name,Taints:.spec.taints Add a comment 97
The simplest way to do this without using any extra tools such as JQ is to use the custom-columns output option.
$ kubectl get nodes -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints –no-headers
Output:
master-11 [map[effect:PreferNoSchedule key:node-role.kubernetes.io/master]] master-12 [map[effect:PreferNoSchedule key:node-role.kubernetes.io/master]] master-13 [map[effect:PreferNoSchedule key:node-role.kubernetes.io/master]] With something like Taints where it is a map or list and you want it to look clean for parsing with some other tool you can clean them up using you can use something similar to the answer by Edwin Tai but with a little extra smarts to extract the keys.
kubectl get nodes -o=jsonpath=’{range .items[]}{.metadata.name}{“\t”}{.spec.taints[].key}{“\n”}{end}’ Output:
master-11 node-role.kubernetes.io/master master-12 node-role.kubernetes.io/master master-13 node-role.kubernetes.io/master worker-21 thegoldfish.org/storage thegoldfish.org/compute worker-22 thegoldfish.org/storage thegoldfish.org/compute worker-23 thegoldfish.org/compute worker-24 thegoldfish.org/storage thegoldfish.org/compute Extra examples: Using this method you can easily create custom outputs
Quick overview of nodes:
kubectl get nodes -o custom-columns=NAME:.metadata.name,ARCH:.status.nodeInfo.architecture,KERNEL:.status.nodeInfo.kernelVersion,KUBLET:.status.nodeInfo.kubeletVersion,CPU:.status.capacity.cpu,RAM:.status.capacity.memory Output:
NAME ARCH KERNEL KUBLET CPU RAM master-11 amd64 3.10.0-1062.9.1.el7.x86_64 v1.17.0 6 7910096Ki master-12 amd64 3.10.0-1062.9.1.el7.x86_64 v1.17.0 6 7910096Ki master-13 amd64 3.10.0-1062.9.1.el7.x86_64 v1.17.0 6 7910096Ki Overview of pods and where to find them sorted by creation time:
kubectl get pods -A -o custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,NODE:.spec.nodeName,HOSTIP:.status.hostIP,PHASE:.status.phase,START_TIME:.metadata.creationTimestamp –sort-by=.metadata.creationTimestamp Output:
NAMESPACE NAME NODE HOSTIP PHASE START_TIME kube-system kube-proxy-rhmrz master-11 192.168.121.108 Running 2019-12-26T14:22:03Z kube-system coredns-6955765f44-777v9 master-11 192.168.121.108 Running 2019-12-26T14:22:03Z kube-system coredns-6955765f44-w7rch master-11 192.168.121.108 Running 2019-12-26T14:22:03Z kube-system kube-scheduler-master-11 master-11 192.168.121.108 Running 2019-12-26T14:22:05Z kube-system kube-controller-manager-master-11 master-11 192.168.121.108 Running 2019-12-26T14:22:05Z kube-system etcd-master-11 master-11 192.168.121.108 Running 2019-12-26T14:22:05Z kube-system kube-apiserver-master-11 master-11 192.168.121.108 Running 2019-12-26T14:22:05Z kube-system calico-node-sxls8 master-11 192.168.121.108 Running 2019-12-26T14:55:41Z kube-system calico-kube-controllers-6d85fdfbd8-dnpn4 master-11 192.168.121.108 Running 2019-12-26T14:55:41Z kubernetes-dashboard dashboard-metrics-scraper-76585494d8-jx9cg master-11 192.168.121.108 Running 2019-12-26T16:10:16Z kubernetes-dashboard kubernetes-dashboard-5996555fd8-5z5p2 master-11 192.168.121.108 Running 2019-12-26T16:10:16Z The documentation for this is https://kubernetes.io/docs/reference/kubectl/overview/#custom-columns
Share Improve this answer Follow edited Dec 27, 2019 at 1:15 answered Dec 27, 2019 at 0:52 Tim Hughes’s user avatar Tim Hughes 3,61222 gold badges2626 silver badges2424 bronze badges Comments
45
In Kubernetes 1.6.x the node taints have moved into the spec. Therefore the above answer by jaxxstorm will not work. Instead, you can use the following 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}} I have that saved into a file and then reference it like so:
kubectl get nodes -o go-template-file=”./nodes-taints.tmpl” You’ll get output like so:
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 I’m not a huge go template user so I’m sure there are some things I could have done better but it is what it is.
Same as above but all in one line:
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}}’ Share Improve this answer Follow edited May 28, 2019 at 16:44 FGreg’s user avatar FGreg 15.6k1010 gold badges7474 silver badges114114 bronze badges answered Jun 7, 2017 at 15:53 Brett Wagner’s user avatar Brett Wagner 1,15422 gold badges1111 silver badges1818 bronze badges Comments
24
To find taints of node can just run:
kubectl describe nodes your-node-name Output:
Name: your-node-name … Taints: node-role.kubernetes.io/master:NoSchedule CreationTimestamp: Wed, 19 Jul 2017 06:00:23 +0800 Share Improve this answer Follow answered Jul 19, 2017 at 15:40 Pavel Evstigneev’s user avatar Pavel Evstigneev 5,1363636 silver badges2121 bronze badges 1 Comment
Lilanga Over a year ago this is handy when used with grep to filter out other information. kubectl describe nodes your-node-name | grep Taints 18
#Check Node Taints kubectl get nodes -o=custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[].key,TaintValue:.spec.taints[].value,TaintEffect:.spec.taints[*].effect Let me try and explain what this first one means and then rest should fall in place:
NodeName:.metadata.name
ColumnName: JSONPATH to the attribute you are looking for.
ColumnName can be anything you want it to be.
Something like NodeName:items[].metadata.name is equivalent to running $kubectl get nodes -o=jsonpath=’{.items[].metadata.name}’ but with custom-columns flag you get values in rows and columns format.
Note: You don’t need to start with .items[*]. It already parses that with custom-column flag
so now all the columns explained:
NodeName:.metadata.name - Get Node Names and put it under NodeName Column
TaintKey:.spec.taints[*].key - return all the keys for taints by looking under taints map and put it under TaintKey custom-column
TaintValue:.spec.taints[*].value - same as key but you are returning the value from the taints map.
TaintEffect:.spec.taints[*].effect - same as key but you are returning the effect from the taints map.
You set it under and alias like
alias get-nodetaints=”kubectl get nodes -o=custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[].key,TaintValue:.spec.taints[].value,TaintEffect:.spec.taints[*].effect” and you have your own nice command to get all taints and your output should look something like below
sample output for the command
Share Improve this answer Follow edited Nov 26, 2020 at 15:50 answered Nov 25, 2020 at 12:00 Sandeep Arora’s user avatar Sandeep Arora 51955 silver badges44 bronze badges 2 Comments
jeje Over a year ago Hi Sandeep, great to give an actionable command, but maybe you can explain a little bit your command?
Sandeep Arora Over a year ago Hello @jeje - I hope the explanation help! 11
Try this one:
kubectl get nodes -o=custom-columns=NAME:.metadata.name,TAINTS:.spec.taints Share Improve this answer Follow answered Oct 18, 2020 at 19:07 scubakiz's user avatar scubakiz 32244 silver badges99 bronze badges Comments
4
| PowerShell:> kubectl describe nodes | findstr “Taint Hostname” |
or
| Bash# kubectl describe nodes | egrep -hi “Taint | Hostname” |
This command is mad easy to remember
Output looks like this:
Taints:
| Bash# kubectl describe nodes -l=cloud.google.com/gke-nodepool=pool-1 | grep Taints -A 3 |
Share Improve this answer Follow edited Feb 5, 2024 at 19:38 answered Jul 15, 2018 at 19:56 neoakris’s user avatar neoakris 5,28333 gold badges3939 silver badges4646 bronze badges 3 Comments
Bogd Over a year ago The syntax seems to be incorrect here - there is no line containing “Taint Hostname”, so grep will not find anything. I think this should be kubectl describe nodes | egrep “Taint|Hostname”
neoakris Over a year ago Thanks your right, I only tested the powershell code, and made assumption that Bash’s grep would be similar but didn’t test, I’ll edit my answer.
jareks Over a year ago Version I use, which puts name first: $ kubectl describe nodes | grep -E ‘Name:|Taint’ Add a comment 3
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 Share Improve this answer Follow edited May 30, 2018 at 12:26 tk3’s user avatar tk3 99611 gold badge1313 silver badges1818 bronze badges answered May 30, 2018 at 10:45 user9869741’s user avatar user9869741 3111 bronze badge 1 Comment
Brett Wagner Over a year ago This should be a separate question. 2
You can use kubectl’s go-template output options to help you here,
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}}’
On my cluster, this prints my masters, which are tainted:
kubemaster-1.example.net kubemaster-2.example.net kubemaster-3.example.net Share Improve this answer Follow edited Sep 27, 2018 at 17:03 Rico’s user avatar Rico 62.1k1212 gold badges121121 silver badges156156 bronze badges answered Apr 12, 2017 at 21:29 jaxxstorm’s user avatar jaxxstorm 13.5k77 gold badges6363 silver badges7171 bronze badges 1 Comment
Brett Wagner Over a year ago This no longer works in 1.6.x preparing a more complete answer for 1.6.x 2
The CMD kubectl provides an arguments jsonpath to search and format the output after getting. You can check the doc k8s jsonpath for detail.
kubectl get node -o=jsonpath=’{range .items[*]}{.metadata.name}{“\t”}{.spec.taints}{“\n”}{end}’ For further info, you can check the source code that reflect the source data with the method FindResults
Share Improve this answer Follow edited Nov 20, 2019 at 0:58 answered Nov 18, 2019 at 5:40 Edwin Tai’s user avatar Edwin Tai 1,33411 gold badge1313 silver badges1919 bronze badges 4 Comments
Yunnosch Over a year ago You did not convince me that this can help. Please explain how it works and how it solves the problem.
Edwin Tai Over a year ago it provides an arguments jsonpath to search and format the output after getting. You can check the doc kubernetes.io/docs/reference/kubectl/jsonpath for detail.
Edwin Tai Over a year ago For further info, you can check the source code that reflect the source data with the method FindResults github.com/kubernetes/kubectl/blob/master/pkg/cmd/get/…
Yunnosch Over a year ago Are you aware that you can edit your answer? Your comments would almost make a decent explanation, if they were not so close to link-only posts. I ask because the some ten of your answers I checked you never edited… Add a comment 2
| kubectl describe nodes [node_name] | grep ‘Taints’ |
kubectl get nodes -o json | jq ‘.items[].spec.taints’ –> this last step will require jq installed ( sudo apt install jq)
Share Improve this answer Follow edited Dec 21, 2019 at 19:35 user3956566 answered Dec 21, 2019 at 18:50 Venu’s user avatar Venu 2911 bronze badge Comments
2
Below commands worked for me:
If you have the node IP, You can try kubectl get node $node_ip -o json | jq ‘.spec.taints’ Output: [ { “effect”: “NoSchedule”, “key”: “dedicated” } ]
(OR)
kubectl describe node $node_ip | grep -i Taints Output: Taints: dedicated:NoSchedule To get all Taint config on namespace kubectl get nodes -o json | jq ‘.items[].spec.taints’ Output: [ { “effect”: “NoSchedule”, “key”: “dedicated” } ] Share Improve this answer Follow answered Jun 8, 2021 at 23:03 Ranjith Kumar G’s user avatar Ranjith Kumar G 7133 bronze badges Comments
2
| kubectl describe node node01 | grep -i taints |
Share Improve this answer Follow answered Apr 10, 2022 at 12:55 Usri’s user avatar Usri 2933 bronze badges 2 Comments
Community Over a year ago As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help centre.
Yunnosch Over a year ago While this code may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply. 1
You can simply run below command:
kubectl describe node node_name | grep ‘Taints’ Share Improve this answer Follow answered Mar 2, 2023 at 10:12 Islam Salah’s user avatar Islam Salah 2,20611 gold badge88 silver badges88 bronze badges Comments
1
| Another alternative is: kubectl describe node | grep -e “Hostname” -e “Taints” |
| Alternatively, you can also do this for a specific node: kubectl describe node pccc-338-5-pool2-j9f2h | grep -e “Hostname” -e “Taints” |