Created
August 16, 2020 11:45
-
-
Save imixtron/4c9a588ba094c313308289b2dcea9c39 to your computer and use it in GitHub Desktop.
Delete unmounted pvc's across cluster
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
# 👏 https://stackoverflow.com/questions/53202727/how-to-delete-only-unmounted-pvcs-and-pvs#answer-59758937 | |
# List Unmounter PVC's | |
kubectl describe -A pvc | grep -E "^Name:.*$|^Namespace:.*$|^Mounted By:.*$" |\ | |
grep -B 2 "<none>" | grep -E "^Name:.*$|^Namespace:.*$" | |
# Delete Unmounted PVC's | |
kubectl describe -A pvc | grep -E "^Name:.*$|^Namespace:.*$|^Mounted By:.*$" |\ | |
grep -B 2 "<none>" | grep -E "^Name:.*$|^Namespace:.*$" | cut -f2 -d: |\ | |
paste -d " " - - | xargs -n2 bash -c 'kubectl -n ${1} delete pvc ${0}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment