The repository is organized into several key directories:
βββ app
β βββ app.py
β βββ calculator.js
β βββ calculator.test.js
β βββ Dockerfile
β βββ Dockerfile-python
β βββ index.js
β βββ package.json
βββ kustomize
β βββ base
β β βββ deploy.yaml
β β βββ ingress.yaml
β β βββ kustomization.yaml
β β βββ svc.yaml
β βββ overlays
β βββ dev
β β βββ deploy-dev.yaml
β β βββ ingress-dev.yaml
β β βββ kustomization.yaml
β β βββ svc-dev.yaml
β βββ prod
β β βββ deploy-prod.yaml
β β βββ ingress-prod.yaml
β β βββ kustomization.yaml
β β βββ svc-prod.yaml
β βββ staging
β βββ deploy-staging.yaml
β βββ ingress-staging.yaml
β βββ kustomization.yaml
β βββ svc-staging.yaml
βββ README.md
βββ terraform
β βββ ingress-nginx.tf
β βββ main.tf
β βββ outputs.tf
β βββ terraform.tf
β βββ variables.tf
βββ VERSION
The build
job performs several key tasks:
- Environment Setup: Node.js environment is set up and dependencies are installed.
- Run Tests: Executes unit tests for the application.
- Determine Version Increment: Checks the commit message to determine if the version needs to be incremented using Semantic Versioning scheme.
- Docker Build and Push: Builds a Docker image and pushes it to a registry.
The deployment
job handles the following:
- Terraform Setup: Initializes Terraform and sets up the backend with different state files.
- Terraform Plan and Apply: Executes
terraform plan
andterraform apply
to provision environment specific infrastructure. - Kubernetes Configuration: Configures
kubectl
to interact with the Kubernetes cluster. - Ingress Controller Setup: Uses Helm to install the ingress controller.
- Application Deployment: Uses
kubectl
to deploy theKustomized
application manifests.
- Dev Environment: Uses
t3.small
EC2 instances and deploys a single replica. - Staging Environment: Uses
t3.medium
EC2 instances and deploys three replicas. - Prod Environment: Uses
t3.large
EC2 instances and deploys three replicas.
DNS for all environments is automatically managed via Cloudflare and environment-specific subdomains are assigned and pointed to their respective LB hostname (using CNAME) ie., dev.afraz.dev
, staging.afraz.dev
and prod.afraz.dev
.
Slack notifications are configured to send updates at the end of each job. This provides immediate feedback on the success or failure of the pipeline and also updates on the DNS changes if applicable.
The pipeline adheres to GitOps principles, where Git serves as the single source of truth. Any change to the application or infrastructure is expected to be made through a Git commit.
If you are planning to use this repo for learning, please hit the star. Thanks!