Skip to content

Instantly share code, notes, and snippets.

@corkupine
Created August 29, 2023 20:52
Show Gist options
  • Save corkupine/f0c9e3844f1807ba7387b12508fc6823 to your computer and use it in GitHub Desktop.
Save corkupine/f0c9e3844f1807ba7387b12508fc6823 to your computer and use it in GitHub Desktop.
Get pods, nodes and zones
#!/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