This project demonstrates a fully automated CI/CD pipeline using Jenkins, Terraform, and Google Cloud Platform (GCP). It is designed to streamline the deployment process while ensuring reliability and scalability.
- Terraform: Infrastructure as Code (IaC) for provisioning cloud resources.
- Jenkins: Automating build, test, and deployment processes.
- Docker: Containerization of applications for portability.
- Google Kubernetes Engine (GKE): Orchestrating containerized workloads.
- Google Artifact Registry: Storing and managing Docker images.
Before running Terraform, enable the necessary APIs:
gcloud services enable container.googleapis.com
gcloud services enable compute.googleapis.com
gcloud services enable artifactregistry.googleapis.com
gcloud services enable cloudresourcemanager.googleapis.comEnsure Terraform is installed and authenticated with GCP. Configure your project and region:
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your project and regionBy default, Terraform will create a dedicated VPC, a Jenkins subnet, and a restricted GKE subnet,
and the GKE control plane will use a private endpoint. Run Jenkins inside the VPC (the Jenkins
subnet is created for this), or set enable_private_endpoint = false and update
jenkins_subnet_cidr to your Jenkins public IP/CIDR.
Then, deploy the infrastructure:
terraform init
terraform apply -auto-approve- Install the following Jenkins plugins:
- Blue Ocean (for modern UI and pipeline visualization)
- Terraform (to integrate with Terraform)
- Docker (to build and push images)
- Authenticate Jenkins with GCP to push Docker images:
gcloud auth configure-docker asia-southeast1-docker.pkg.devUpdate the Jenkinsfile environment values to match your project:
PROJECTREGIONIMAGE_REPOCLUSTER_NAME
The Jenkinsfile defines the complete CI/CD pipeline, including:
- Code Checkout: Fetching source code from version control.
- Build & Test: Running unit tests and security scans.
- Containerization: Building Docker images.
- Artifact Management: Pushing images to Google Artifact Registry.
- Deployment: Deploying to GKE.
The pipeline replaces the IMAGE_PATH placeholder in deployment.yaml before applying it.
This repo includes a GitOps-ready Kustomize setup in k8s/ and an Argo CD
Application manifest in argocd/application.yaml.
- Install Argo CD:
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml- Update
argocd/application.yaml:
repoURL-> your repo URLtargetRevision-> your branch or tag
- Set your image repo in
k8s/kustomization.yaml:
kustomize edit set image IMAGE_PATH=asia-southeast1-docker.pkg.dev/PROJECT_ID/cloud-automator/check:latest- Create the Argo CD application:
kubectl apply -n argocd -f argocd/application.yamlIf you use Argo CD for deployments, you can skip the Jenkins deploy stage and
let Argo CD sync from Git whenever you update k8s/kustomization.yaml.
The k8s/ folder also includes a simple open-source frontend and backend:
- Frontend:
nginx:1.25-alpine(LoadBalancer service) - Backend:
kennethreitz/httpbin:latest(ClusterIP service)
These are already part of the Kustomize base, so Argo CD will deploy them
alongside the main app unless you remove them from k8s/kustomization.yaml.
✔️ Infrastructure as Code (IaC) with Terraform
✔️ Automated deployments with Jenkins
✔️ Managing containerized applications on GKE
✔️ Secure artifact storage with Google Artifact Registry
✔️ End-to-end CI/CD implementation