Skip to content

Commit ce78ad0

Browse files
committed
Refactor GitHub Actions workflows and Terraform configurations; update image tag handling, add ArgoCD installation, and configure providers for Kubernetes and Helm.
1 parent e26914e commit ce78ad0

File tree

6 files changed

+101
-38
lines changed

6 files changed

+101
-38
lines changed

.github/workflows/deploy.yml

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -65,40 +65,16 @@ jobs:
6565
MONGO_PASSWORD: $(echo -n "${{ secrets.MONGO_PASSWORD }}" | base64)
6666
EOF
6767
68-
# - name: Generate Deployment YAML with Docker image
69-
# run: |
70-
# IMAGE_TAG=${{ inputs.image-tag || github.sha }}
71-
# envsubst < ./kubernetes/deployment.template.yml > ./kubernetes/deployment.yml
72-
# env:
73-
# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
74-
# IMAGE_TAG: ${{ inputs.image-tag || github.sha }}
75-
76-
- name: Setup helm
77-
uses: azure/setup-helm@v4
78-
with:
79-
version: v3.5.4
80-
81-
82-
- name: Deploy with helm
68+
- name: Update Helm values with new image tag
8369
run: |
8470
IMAGE_TAG=${{ inputs.image-tag || github.sha }}
85-
helm upgrade --install solar-system ./helm \
86-
--set image.repository=ghcr.io/${{ secrets.DOCKER_USERNAME }}/graduation-project-devops \
87-
--set image.tag=$IMAGE_TAG \
88-
--namespace default \
89-
--create-namespace
90-
91-
- name: Verify Deployment
92-
run: |
93-
kubectl get pods -l app=solar-system
94-
kubectl get services
95-
echo "Waiting for deployment to be ready..."
96-
kubectl wait --for=condition=available --timeout=300s deployment/solar-system
97-
echo "Waiting for container to be running..."
98-
kubectl wait --for=condition=Ready --timeout=180s pod -l app=solar-system
99-
100-
- name: Get Service URL
71+
# Update the image tag in values.yaml for ArgoCD to pick up
72+
sed -i "s|tag: \".*\"|tag: \"$IMAGE_TAG\"|g" ./helm/values.yaml
73+
74+
- name: Commit updated image tag
10175
run: |
102-
HOSTNAME=$(kubectl get svc solar-system-svc -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
103-
echo "Service URL: http://$HOSTNAME"
104-
working-directory: ./kubernetes
76+
git config --local user.email "[email protected]"
77+
git config --local user.name "GitHub Action"
78+
git add helm/values.yaml
79+
git commit -m "Update image tag to ${{ inputs.image-tag || github.sha }}" || exit 0
80+
git push

.github/workflows/main-pipeline.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ on:
2323
required: false
2424
default: false
2525
type: boolean
26-
push:
27-
branches:
28-
- main
29-
- 'feature-branch-A'
3026

3127
permissions:
3228
contents: read

.github/workflows/terraform.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,39 @@ jobs:
5151
if: ${{ inputs.terraform-action == 'apply' || inputs.terraform-action == '' }}
5252
run: terraform apply -auto-approve
5353
working-directory: ./Terraform
54+
55+
- name: Update kubeconfig
56+
if: ${{ inputs.terraform-action == 'apply' || inputs.terraform-action == '' }}
57+
run: |
58+
aws eks update-kubeconfig --name otel-cluster --region us-east-1
59+
60+
- name: Wait for ArgoCD LoadBalancer
61+
if: ${{ inputs.terraform-action == 'apply' || inputs.terraform-action == '' }}
62+
run: |
63+
echo "Waiting for ArgoCD LoadBalancer to be ready..."
64+
kubectl wait --for=condition=available --timeout=300s deployment/argocd-server -n argocd || true
65+
sleep 30
66+
67+
- name: Get ArgoCD Access Info
68+
if: ${{ inputs.terraform-action == 'apply' || inputs.terraform-action == '' }}
69+
run: |
70+
echo "=========================================="
71+
echo "🚀 ARGOCD ACCESS INFORMATION"
72+
echo "=========================================="
73+
74+
# Get ArgoCD URL
75+
ARGOCD_URL=$(kubectl get svc argocd-server -n argocd -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo "Still loading...")
76+
echo "📋 ArgoCD URL: http://$ARGOCD_URL"
77+
78+
# Get admin password
79+
ARGOCD_PASSWORD=$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' 2>/dev/null | base64 -d || echo "Secret not ready yet")
80+
echo "🔑 Username: admin"
81+
echo "🔑 Password: $ARGOCD_PASSWORD"
82+
83+
echo "=========================================="
84+
echo "📝 Instructions:"
85+
echo "1. Wait a few minutes for LoadBalancer DNS to propagate"
86+
echo "2. Access: http://$ARGOCD_URL"
87+
echo "3. Login with username 'admin' and password above"
88+
echo "4. Your solar-system app should appear automatically"
89+
echo "=========================================="

Terraform/0-versions.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,13 @@ terraform {
55
source = "hashicorp/aws"
66
version = "~> 5.0"
77
}
8+
helm = {
9+
source = "hashicorp/helm"
10+
version = "~> 2.12"
11+
}
12+
kubernetes = {
13+
source = "hashicorp/kubernetes"
14+
version = "~> 2.25"
15+
}
816
}
917
}

Terraform/1-provider.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,29 @@ provider "aws" {
33
region = "us-east-1"
44
}
55

6+
# Configure the Kubernetes Provider
7+
provider "kubernetes" {
8+
host = module.eks.cluster_endpoint
9+
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
10+
11+
exec {
12+
api_version = "client.authentication.k8s.io/v1beta1"
13+
command = "aws"
14+
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name]
15+
}
16+
}
17+
18+
# Configure the Helm Provider
19+
provider "helm" {
20+
kubernetes {
21+
host = module.eks.cluster_endpoint
22+
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
23+
24+
exec {
25+
api_version = "client.authentication.k8s.io/v1beta1"
26+
command = "aws"
27+
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name]
28+
}
29+
}
30+
}
31+

Terraform/3-main.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,26 @@ module "eks" {
1616
vpc_id = module.vpc.vpc_id
1717
subnet_ids = module.vpc.private_subnet_ids
1818
node_groups = var.node_groups
19+
}
20+
21+
# Install ArgoCD
22+
resource "helm_release" "argocd" {
23+
name = "argocd"
24+
repository = "https://argoproj.github.io/argo-helm"
25+
chart = "argo-cd"
26+
namespace = "argocd"
27+
28+
create_namespace = true
29+
30+
set {
31+
name = "server.service.type"
32+
value = "LoadBalancer"
33+
}
34+
35+
set {
36+
name = "server.extraArgs[0]"
37+
value = "--insecure"
38+
}
1939

40+
depends_on = [module.eks]
2041
}

0 commit comments

Comments
 (0)