-
Notifications
You must be signed in to change notification settings - Fork 1.3k
App Deployment on AWS EKS with Terraform & CI/CD #13
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
base: main
Are you sure you want to change the base?
Changes from all commits
b059400
06debd2
eecdfe8
7cc18cb
42c8e7c
3bd8029
613967a
d2f25d3
0370e3c
e28e56b
8fa5242
6fd371d
bdf52a2
c0dc1a9
c4e9bb1
8b4c485
9efc98c
c9a5e58
bf60fb9
71f1bc6
7e2ee27
7c3347f
77f3a4e
f8de708
fa4d7c8
da5f615
a9e83a1
4dc3c35
4fe84c5
27d1e96
858f401
93e808c
ffa6afc
e317ef4
40ff5fe
a43a091
5045a2a
04338d3
c807bfc
59fe734
aaf8d60
e84c9c9
cfb262e
19b2404
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| stages: | ||
| - build | ||
| - push | ||
| - deploy | ||
|
|
||
| variables: | ||
| DOCKER_DRIVER: overlay2 | ||
| IMAGE_TAG: "v$CI_PIPELINE_ID" | ||
|
|
||
| build_backend: | ||
| stage: build | ||
| script: | ||
| - docker build -t $ECR_BACKEND_REPO:$IMAGE_TAG ./backend | ||
| tags: | ||
| - self-hosted | ||
|
|
||
| build_frontend: | ||
| stage: build | ||
| script: | ||
| - docker build -t $ECR_FRONTEND_REPO:$IMAGE_TAG ./frontend | ||
| tags: | ||
| - self-hosted | ||
|
|
||
| push_backend: | ||
| stage: push | ||
| script: | ||
| - aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_BACKEND_REPO | ||
| - docker push $ECR_BACKEND_REPO:$IMAGE_TAG | ||
| tags: | ||
| - self-hosted | ||
|
|
||
| push_frontend: | ||
| stage: push | ||
| script: | ||
| - aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_FRONTEND_REPO | ||
| - docker push $ECR_FRONTEND_REPO:$IMAGE_TAG | ||
| tags: | ||
| - self-hosted | ||
|
|
||
| deploy: | ||
| stage: deploy | ||
| script: | ||
| - aws eks update-kubeconfig --region us-east-2 --name chatapp-cluster | ||
| - kubectl config use-context arn:aws:eks:us-east-2:339932683794:cluster/chatapp-cluster | ||
| - kubectl apply -f k8s/namespace.yaml | ||
| - kubectl apply -f k8s/mongodb-secret.yaml | ||
| - kubectl apply -f k8s/mongodb-configmap.yaml | ||
| - kubectl apply -f k8s/mongo-pv.yaml | ||
| - kubectl apply -f k8s/mongo-pvc.yaml | ||
| - kubectl apply -f k8s/mongodb-deployment.yaml | ||
| - kubectl apply -f k8s/mongodb-service.yaml | ||
| - kubectl apply -f k8s/backend-secrets.yaml | ||
| - kubectl apply -f k8s/backend-service.yaml | ||
| - sed "s|IMAGE_PLACEHOLDER|$ECR_BACKEND_REPO:$IMAGE_TAG|g" k8s/backend-deployment.yaml > k8s/_backend-deployment.yaml | ||
| - kubectl apply -f k8s/_backend-deployment.yaml | ||
| - kubectl apply -f k8s/backend-hpa.yaml | ||
| - kubectl apply -f k8s/frontend-configmap.yaml | ||
| - kubectl apply -f k8s/frontend-service.yaml | ||
| - sed "s|IMAGE_PLACEHOLDER|$ECR_FRONTEND_REPO:$IMAGE_TAG|g" k8s/frontend-deployment.yaml > k8s/_frontend-deployment.yaml | ||
| - kubectl apply -f k8s/_frontend-deployment.yaml | ||
| - kubectl apply -f k8s/frontend-hpa.yaml | ||
| - kubectl apply -f k8s/frontend-ingress.yaml | ||
| - kubectl apply -f k8s/metrics-server.yaml | ||
| only: | ||
| - DevOps | ||
| tags: | ||
| - self-hosted | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| stages: | ||
| - plan | ||
| - apply | ||
|
|
||
|
Comment on lines
+1
to
+4
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. Convert CRLF to LF – current line endings break linters
🧰 Tools🪛 YAMLlint (1.37.1)[error] 1-1: wrong new line character: expected \n (new-lines) 🤖 Prompt for AI Agents |
||
| variables: | ||
| TF_IN_AUTOMATION: "true" | ||
| TF_INPUT: "false" | ||
|
|
||
|
|
||
|
|
||
| plan_eks: | ||
| stage: plan | ||
| script: | ||
| - cd infra/eks | ||
| - terraform init -reconfigure | ||
| - terraform plan -out=tfplan | ||
| tags: | ||
| - self-hosted | ||
| artifacts: | ||
| paths: | ||
| - infra/eks/tfplan | ||
| expire_in: 1 hour | ||
|
|
||
|
|
||
| apply_eks: | ||
| stage: apply | ||
| script: | ||
| - cd infra/eks | ||
| - terraform init -reconfigure | ||
| - terraform apply -auto-approve tfplan | ||
| when: manual | ||
| needs: ["plan_eks"] | ||
| tags: | ||
| - self-hosted | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| include: | ||
| #- local: '.gitlab-ci.infra.yml' | ||
| - local: '.gitlab-ci.deploy.yml' |
This file was deleted.
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.
Normalize line endings to LF
Same CRLF issue as
.gitlab-ci.infra.yml; re-commit with Unix line endings to silence YAML lint errors and avoid cross-platform diffs.🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 1-1: wrong new line character: expected \n
(new-lines)
🤖 Prompt for AI Agents