Created
May 3, 2022 19:54
-
-
Save kevsmith/72dd5e924f4ccd30487c9ba42857c8a8 to your computer and use it in GitHub Desktop.
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 | |
# Helper script to clean all persistent volumes (PVs) and persistent volume claims (PVCs) | |
# from a minikube-based environment. | |
# First let's clean persistent volume claims | |
# Get the total lines and subtract one for the header | |
total=$(expr $(kubectl --context minikube get pvc | wc -l) - 1) | |
# Iterate over each PVC and delete | |
for pvc in $(kubectl --context minikube get pvc | tail -n${total} | cut -d' ' -f1) | |
do | |
kubectl --context minikube delete pvc ${pvc} | |
done | |
# Now let's do the underlying persistent volumes | |
total=$(expr $(kubectl --context minikube get pv | wc -l) - 1) | |
for pv in $(kubectl --context minikube get pv | tail -n${total} | cut -d' ' -f1) | |
do | |
kubectl --context minikube delete pv ${pv} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment