Created
August 29, 2023 20:52
-
-
Save corkupine/f0c9e3844f1807ba7387b12508fc6823 to your computer and use it in GitHub Desktop.
Get pods, nodes and zones
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
kubectl get pods --all-namespaces -o custom-columns=":metadata.namespace,:metadata.name,:spec.nodeName" --no-headers=true | while read -r namespace pod_name node_name | |
do | |
zone=$(kubectl get node "$node_name" -o jsonpath="{.metadata.labels.topology\.kubernetes\.io/zone}") | |
echo "Namespace: $namespace, Pod Name: $pod_name, Node Name: $node_name, Zone: $zone" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment