Created
October 6, 2025 02:28
-
-
Save muhammad-asn/ae260a242821c1716fea27c40d5aba5e to your computer and use it in GitHub Desktop.
One Liner get kubernetes pvcs and their zone
This file contains hidden or 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 | |
echo "NAMESPACE PVC PV ZONE"; kubectl get pvc -A -o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{" "}{.spec.volumeName}{"\n"}{end}' | while read ns pvc pv; do echo -n "$ns $pvc $pv "; kubectl get pv "$pv" -o jsonpath='{.spec.nodeAffinity.required.nodeSelectorTerms[*].matchExpressions[?(@.key=="topology.kubernetes.io/zone")].values[*]}' 2>/dev/null; echo; done | column -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment