Question
Add a taint to node worker-2 with effect as NoSchedule and list the nodes with taint effect as NoSchedule
Answer
Add taint to node worker-2:
kubectl taint node worker-2 key=value:NoSchedule
Verify using custom-columns, you can customize which coloumn to be printed:
kubectl get nodes -o custom-columns='NAME:.metadata.name,TAINTS:.spec.taints[*].effect' --no-headers |grep -i noschedule
Same using jsonpath:
kubectl get nodes -o jsonpath="{range .items[*]}{.metadata.name}{'\t'}{.spec.taints[?( @.effect=='NoSchedule' )].effect}{\"\n\"}{end}" | awk 'NF==2 {print $0}'
awk explanation: if the number of items that are present in the line is 2 then the line will be printed - omitting lines with empty taints