Skip to content

Commit 1320e9a

Browse files
committed
Enhance deployment and destroy workflows with improved logging and resource management
- Added deployment completion messages and application URL output in deploy.yml - Updated destroy.yml to only delete LoadBalancer services, allowing Terraform to manage ArgoCD application cleanup - Modified main.tf to set Helm release wait and timeout parameters, ensuring ArgoCD readiness before application creation
1 parent f147b70 commit 1320e9a

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

.github/workflows/destroy.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ jobs:
2828
run: |
2929
aws eks update-kubeconfig --name otel-cluster --region us-east-1 || true
3030
31-
# Delete ArgoCD application (this will clean up all Helm resources)
32-
kubectl delete application solar-system -n argocd || true
33-
34-
# Delete ArgoCD LoadBalancer to avoid Terraform destroy hanging
35-
kubectl delete svc argocd-server -n argocd || true
36-
31+
# Only delete the LoadBalancer services to prevent VPC destruction issues
32+
# Let Terraform handle destroying the ArgoCD application it created
33+
kubectl delete svc argocd-server -n argocd || true
34+
kubectl delete svc solar-system-svc || true
35+
3736
- name: Terraform Init
3837
run: terraform init
3938
working-directory: ./Terraform

Terraform/0-versions.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@ terraform {
1313
source = "hashicorp/kubernetes"
1414
version = "~> 2.25"
1515
}
16+
time = {
17+
source = "hashicorp/time"
18+
version = "~> 0.9"
19+
}
1620
}
1721
}

Terraform/3-main.tf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ resource "helm_release" "argocd" {
2626
namespace = "argocd"
2727

2828
create_namespace = true
29+
wait = true
30+
timeout = 600
2931

3032
set {
3133
name = "server.service.type"
@@ -39,3 +41,41 @@ resource "helm_release" "argocd" {
3941

4042
depends_on = [module.eks]
4143
}
44+
45+
# Wait for ArgoCD to be ready before creating applications
46+
resource "time_sleep" "wait_for_argocd" {
47+
depends_on = [helm_release.argocd]
48+
create_duration = "60s"
49+
}
50+
51+
# Create ArgoCD Application automatically
52+
resource "kubernetes_manifest" "solar_system_app" {
53+
manifest = {
54+
apiVersion = "argoproj.io/v1alpha1"
55+
kind = "Application"
56+
metadata = {
57+
name = "solar-system"
58+
namespace = "argocd"
59+
}
60+
spec = {
61+
project = "default"
62+
source = {
63+
repoURL = "https://github.com/KarimZakzouk/Graduation-Project-Devops"
64+
targetRevision = "HEAD"
65+
path = "helm"
66+
}
67+
destination = {
68+
server = "https://kubernetes.default.svc"
69+
namespace = "default"
70+
}
71+
syncPolicy = {
72+
automated = {
73+
prune = true
74+
selfHeal = true
75+
}
76+
}
77+
}
78+
}
79+
80+
depends_on = [time_sleep.wait_for_argocd]
81+
}

0 commit comments

Comments
 (0)