# Get all control-plane nodes
kubectl get nodes -o json | jq -r '.items[] | select(.metadata.labels."node-role.kubernetes.io/control-plane"=="true").metadata.name'
# Get all worker nodes
kubectl get nodes -o json | jq -r '.items[] | select(.metadata.labels."node-role.kubernetes.io/control-plane"!="true").metadata.name'
Created
March 20, 2024 01:46
-
-
Save zulhfreelancer/8a3c5c5a2cc61e320f886183c0d35c98 to your computer and use it in GitHub Desktop.
How to filter Kubernetes nodes by label using kubectl and jq
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment