Skip to content

Commit 8249cac

Browse files
author
Miguel Varela Ramos
committed
Delete Prometheus PVC prior to cluster deletion to delete provisioned disk
1 parent cd2200c commit 8249cac

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

cli/cmd/cluster_gcp.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ var _clusterGCPDownCmd = &cobra.Command{
263263

264264
fmt.Print("○ spinning down the cluster ")
265265

266+
_, _, err = runGCPManagerAccessCommand("/root/uninstall.sh", *accessConfig, nil, nil)
267+
if err != nil {
268+
exit.Error(err)
269+
}
270+
266271
_, err = gcpClient.DeleteCluster(gkeClusterName)
267272
if err != nil {
268273
fmt.Print("\n\n")

manager/uninstall.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,36 @@ set -e
1818

1919
EKSCTL_TIMEOUT=45m
2020

21-
echo
21+
function main() {
22+
if [ "$CORTEX_PROVIDER" == "aws" ]; then
23+
uninstall_aws
24+
elif [ "$CORTEX_PROVIDER" == "gcp" ]; then
25+
uninstall_gcp
26+
fi
27+
}
2228

23-
eksctl delete cluster --wait --name=$CORTEX_CLUSTER_NAME --region=$CORTEX_REGION --timeout=$EKSCTL_TIMEOUT
29+
function uninstall_gcp() {
30+
gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS 2> /dev/stdout 1> /dev/null | (grep -v "Activated service account credentials" || true)
31+
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)
2432

25-
echo -e "\n✓ done spinning down the cluster"
33+
uninstall_prometheus
34+
}
35+
36+
function uninstall_aws() {
37+
echo
38+
39+
uninstall_prometheus
40+
41+
eksctl delete cluster --wait --name=$CORTEX_CLUSTER_NAME --region=$CORTEX_REGION --timeout=$EKSCTL_TIMEOUT
42+
echo -e "\n✓ done spinning down the cluster"
43+
}
44+
45+
function uninstall_prometheus() {
46+
kubectl get configmap cluster-config -o jsonpath='{.data.cluster\.yaml}' > ./cluster.yaml
47+
48+
# delete resources to detach disk
49+
python render_template.py ./cluster.yaml manifests/prometheus-monitoring.yaml.j2 | kubectl delete -f - >/dev/null
50+
kubectl delete pvc prometheus-prometheus-db-prometheus-prometheus-0 >/dev/null
51+
}
52+
53+
main

0 commit comments

Comments
 (0)