-
Notifications
You must be signed in to change notification settings - Fork 606
Delete unused prometheus volume on cluster down #1863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8249cac
Delete Prometheus PVC prior to cluster deletion to delete provisioned…
2743b3f
Update kubeconfig on uninstall_aws in uninstall.sh
cc22509
Add flag to explicitly delete volumes and delete grafana storage
91fc401
Merge branch 'master' into cleanup-pvc
ffccf65
Update docs
62be59b
Merge branch 'master' into cleanup-pvc
RobertLucian 7c3ec6e
Merge branch 'master' into cleanup-pvc
RobertLucian 786dd9e
Best-effort removal of k8s components
RobertLucian 9afd9f8
Merge branch 'master' into cleanup-pvc
vishalbollu 3a234e5
Better error message
RobertLucian 9942b8b
Improve error message for cluster down on GCP
RobertLucian 887c633
Further improve error message for gcp cluster down
RobertLucian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,51 @@ set -e | |
|
||
EKSCTL_TIMEOUT=45m | ||
|
||
echo | ||
arg1="$1" | ||
|
||
eksctl delete cluster --wait --name=$CORTEX_CLUSTER_NAME --region=$CORTEX_REGION --timeout=$EKSCTL_TIMEOUT | ||
function main() { | ||
if [ "$CORTEX_PROVIDER" == "aws" ]; then | ||
uninstall_aws | ||
elif [ "$CORTEX_PROVIDER" == "gcp" ]; then | ||
uninstall_gcp | ||
fi | ||
} | ||
|
||
echo -e "\n✓ done spinning down the cluster" | ||
function uninstall_gcp() { | ||
gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS 2> /dev/stdout 1> /dev/null | (grep -v "Activated service account credentials" || true) | ||
gcloud container clusters get-credentials $CORTEX_CLUSTER_NAME --project $CORTEX_GCP_PROJECT --region $CORTEX_GCP_ZONE 2> /dev/stdout 1> /dev/null | (grep -v "Fetching cluster" | grep -v "kubeconfig entry generated" || true) | ||
|
||
if [ "$arg1" != "--keep-volumes" ]; then | ||
uninstall_prometheus | ||
uninstall_grafana | ||
fi | ||
} | ||
|
||
function uninstall_aws() { | ||
echo | ||
|
||
aws eks --region $CORTEX_REGION update-kubeconfig --name $CORTEX_CLUSTER_NAME >/dev/null | ||
|
||
if [ "$arg1" != "--keep-volumes" ]; then | ||
uninstall_prometheus | ||
uninstall_grafana | ||
fi | ||
|
||
eksctl delete cluster --wait --name=$CORTEX_CLUSTER_NAME --region=$CORTEX_REGION --timeout=$EKSCTL_TIMEOUT | ||
echo -e "\n✓ done spinning down the cluster" | ||
} | ||
|
||
function uninstall_prometheus() { | ||
kubectl get configmap cluster-config -o jsonpath='{.data.cluster\.yaml}' > ./cluster.yaml | ||
|
||
# delete resources to detach disk | ||
python render_template.py ./cluster.yaml manifests/prometheus-monitoring.yaml.j2 | kubectl delete -f - >/dev/null | ||
kubectl delete pvc --namespace default prometheus-prometheus-db-prometheus-prometheus-0 >/dev/null | ||
} | ||
|
||
function uninstall_grafana() { | ||
kubectl delete statefulset --namespace default grafana >/dev/null | ||
kubectl delete pvc --namespace default grafana-storage >/dev/null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a scenario where cluster-down fails, it may not be possible to get kube config to delete the volumes via kubectl. We should use cloud specific apis to find and delete volumes without having to rely on kubectl. |
||
} | ||
|
||
main |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flag might be renamed to --keep-cloud-resources so that it can be used to preserver volumes, buckets, policies and log groups. For now I think it is fine.