Final run of the week 1 series. For some reason the app tracked me at just over 1km, but fitbit tracked me at 4km. Probably quirky gps.
One of the questions in my CKA exam was how to display taints with kubectl. While you can use kubectl describe, it creates a lot of other information too.
Then I found out about jsonpath and it’s similarity to jq
You can display the taints with something like
for a in $(kubectl get nodes --no-headers | awk '{print $1}')
do
echo $a -- $(kubectl get nodes/$a -o jsonpath='{.spec.taints[*].key}{":"}{.spec.taints[*].effect}')
done
Sample output
ip-10-10-10-147.eu-west-2.compute.internal -- node-role.kubernetes.io/master:NoSchedule ip-10-10-10-159.eu-west-2.compute.internal -- :
So the first one has a taint (it’s the master node) and the second one doesn’t.
(maybe I need to hack this a bit more when I have multiple taints but I’ll do that when I have some multi-tainted nodes to play with)
EDIT: Another way as provided by tdodds81
$ kubectl get nodes -o=custom-columns=NAME:.metadata.name,TAINTS:.spec.taints NAME TAINTS ip-10-10-10-148.eu-west-2.compute.internal [map[effect:NoSchedule key:node-role.kubernetes.io/master]] ip-10-10-10-218.eu-west-2.compute.internal ip-10-10-10-239.eu-west-2.compute.internal ip-10-10-10-249.eu-west-2.compute.internal ip-10-10-10-51.eu-west-2.compute.internal
And with multi-taints, it looks like this (on a GKE cluster)
$ kubectl get nodes -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints NAME TAINTS gke-test-cluster-k8s-n1-highmem-2-nod-589548dd-3z1v [map[effect:NoSchedule key:key1 timeAdded:<nil> value:value1] map[value:value2 effect:NoSchedule key:key2 timeAdded:<nil>]] gke-test-cluster-k8s-n1-highmem-2-nod-7a33f13b-9lwk <none> gke-test-cluster-k8s-n1-highmem-2-nod-7a33f13b-lnvl <none> gke-test-cluster-k8s-n1-highmem-2-nod-7a33f13b-nt49 <none> gke-test-cluster-k8s-n1-highmem-2-nod-7a33f13b-xgbd <none>
You must be logged in to post a comment.