Skip to content

RashadTanjim/cloudops-automator

Repository files navigation

CI/CD Pipeline - Cloud Automator

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.

Technologies Used

  • 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.

Setup Instructions

Enable Required Google Cloud APIs

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.com

Infrastructure Deployment with Terraform

Ensure 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 region

By 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

Jenkins Configuration

  • 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.dev

Update the Jenkinsfile environment values to match your project:

  • PROJECT
  • REGION
  • IMAGE_REPO
  • CLUSTER_NAME

CI/CD Pipeline

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.

Argo CD (GitOps)

This repo includes a GitOps-ready Kustomize setup in k8s/ and an Argo CD Application manifest in argocd/application.yaml.

  1. Install Argo CD:
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
  1. Update argocd/application.yaml:
  • repoURL -> your repo URL
  • targetRevision -> your branch or tag
  1. 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
  1. Create the Argo CD application:
kubectl apply -n argocd -f argocd/application.yaml

If 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.

Open Source Frontend/Backend Example

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.

Features:

✔️ 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


About

CI/CD pipeline using Jenkins, Terraform, Argo CD, and Google Cloud Platform (GCP), designed to streamline the deployment process while ensuring reliability and scalability.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors