Skip to content

Commit 00e51a5

Browse files
committed
Refactor destroy workflow to improve organization and add error handling for resource deletions
1 parent bde66b5 commit 00e51a5

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

.github/workflows/destroy.yml

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,50 @@ jobs:
2727
- name: Update kubeconfig
2828
run: aws eks update-kubeconfig --name otel-cluster --region us-east-1
2929

30-
- name: Delete ArgoCD Applications (app + monitoring)
30+
# ---------------------------
31+
# Delete ArgoCD Applications
32+
# ---------------------------
33+
- name: Delete ArgoCD Applications
3134
run: |
32-
kubectl delete application my-app -n argocd || true
33-
kubectl delete application kube-prometheus-stack -n argocd || true
35+
kubectl delete application my-app -n argocd --ignore-not-found
36+
kubectl delete application kube-prometheus-stack -n argocd --ignore-not-found
3437
35-
- name: Delete Monitoring Namespace
36-
run: kubectl delete namespace monitoring || true
37-
38-
- name: Delete App Namespace
39-
run: kubectl delete namespace my-app-namespace || true
38+
# ---------------------------
39+
# Uninstall Helm Releases
40+
# ---------------------------
41+
- name: Uninstall Helm Releases
42+
run: |
43+
helm uninstall my-app -n my-app-namespace || true
44+
helm uninstall kube-prometheus-stack -n monitoring || true
45+
helm uninstall argocd -n argocd || true
4046
47+
# ---------------------------
48+
# Delete Namespaces
49+
# ---------------------------
50+
- name: Delete Namespaces
51+
run: |
52+
kubectl delete namespace my-app-namespace --ignore-not-found
53+
kubectl delete namespace monitoring --ignore-not-found
54+
kubectl delete namespace argocd --ignore-not-found
4155
42-
- name: Uninstall ArgoCD
56+
# ---------------------------
57+
# Delete CRDs (Prometheus & Grafana)
58+
# ---------------------------
59+
- name: Delete CRDs
4360
run: |
44-
helm uninstall argocd -n argocd || true
45-
kubectl delete namespace argocd || true
61+
kubectl get crd -o name | grep -E 'prometheus|grafana|alertmanager|servicemonitor|prometheusrule' | xargs -r kubectl delete || true
4662
47-
- name: Cleanup PVCs (to release EBS volumes)
63+
# ---------------------------
64+
# Cleanup PVCs & PVs
65+
# ---------------------------
66+
- name: Cleanup Persistent Storage
4867
run: |
4968
kubectl delete pvc --all -A || true
5069
kubectl delete pv --all || true
5170
52-
71+
# ---------------------------
72+
# Terraform Destroy
73+
# ---------------------------
5374
- name: Terraform Init
5475
run: terraform init
5576
working-directory: ./Terraform

0 commit comments

Comments
 (0)