Created
August 7, 2024 11:06
-
-
Save mattmattox/0633f7030da2d35cafe300d23d9b06bb 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 | |
# List all Helm releases in the cluster | |
helm list --all-namespaces --short | while read -r release; do | |
echo "Processing release: $release" | |
# Get revision history for the release | |
revisions=$(helm history "$release" --short | tail -n +2) | |
# Keep the latest revision | |
latest_revision=$(echo "$revisions" | head -n 1) | |
# Remove all revisions except the latest | |
echo "$revisions" | while read -r revision; do | |
if [[ "$revision" != "$latest_revision" ]]; then | |
echo "Deleting revision: $revision" | |
helm rollback "$release" "$revision" | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment