Skip to content

3034saurabhkumar/CI-CD_implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CI/CD Pipeline – Spring Boot Application πŸš€

This repository demonstrates an end-to-end CI/CD pipeline using Jenkins, Docker, GitHub, Kubernetes and Argo CD (Operator-based).

image

πŸ”– Key Concepts

CI/CD Β· GitOps Β· Release Management Β· Docker Image Versioning . Kubernetes Deployments Β· Argo CD Sync Β· Jenkins Pipelines

πŸ› οΈ Tech Stack & Tools

  • Source Control: GitHub
  • CI Tool: Jenkins (Declarative Pipeline)
  • Build Tool: Maven
  • Containerization: Docker
  • CD Tool: Argo CD (Installed via Operator & Controllers)
  • Deployment: Kubernetes

πŸ“ Repositories Used

Repository Purpose URL
myFirstProject Spring Boot application source code https://github.com/3034saurabhkumar/myFirstProject
CI-CD_implementation Kubernetes manifests (deployment.yml, service.yml) https://github.com/3034saurabhkumar/CI-CD_implementation

πŸ” CI/CD Workflow Overview

Developer Commit
      ↓
GitHub (Release Branch)
      ↓
Jenkins Pipeline
      ↓
Maven Build
      ↓
Docker Image Build & Push
      ↓
Update Deployment Repo
      ↓
Argo CD Sync
      ↓
Kubernetes Deployment

🧩 Jenkins Pipeline Stages

1️⃣ Prepare Workspace

  • Cleans old workspace
  • Fresh Git checkout

2️⃣ Create Release Branch

  • Creates release-<version> branch
  • Pushes to GitHub using credentials

3️⃣ Build & Test (Dockerized Maven)

  • Runs mvn clean package
  • Generates JAR
  • Stashes build artifact

4️⃣ Docker Build & Push

  • Builds Docker image using JAR
  • Pushes image to Docker Hub
  • Image tag = release version

5️⃣ Update Deployment Repo

  • Clones CI-CD_implementation
  • Updates Docker image tag in deployment.yml
  • Commits & pushes changes to main

6️⃣ Argo CD Deployment

  • Argo CD detects Git change
  • Automatically syncs to Kubernetes cluster

πŸ” Jenkins Credentials

Credential ID Type Usage
github-release-creds Username + Token GitHub push & branch creation
docker-cred Docker Registry Docker image push

🐳 Docker Image Naming Convention

saurabh3034/spring-voldemort:<release-version>

Example saurabh3034/spring-voldemort:1.0.1


πŸš€ Argo CD Setup

  • Installed using Argo CD Operator
  • CRDs and Controllers installed first
  • Application configuration:
    • Repository: CI-CD_implementation
    • Branch: main
    • Path: /
  • Sync Policy: Automated

πŸ—οΈ Architecture Overview

High-Level CI/CD + GitOps Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Developer  β”‚
β”‚ Git Push   β”‚
β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
      β”‚
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ GitHub – App Repo      β”‚
β”‚ myFirstProject         β”‚
β”‚ (release-x.y.z branch) β”‚
β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Jenkins CI             β”‚
β”‚------------------------β”‚
β”‚ β€’ Maven Build          β”‚
β”‚ β€’ Docker Image Build   β”‚
β”‚ β€’ Push to Docker Hub   β”‚
β”‚ β€’ Update Deploy Repo   β”‚
β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ GitHub – Deploy Repo   β”‚
β”‚ CI-CD_implementation   β”‚
β”‚ (deployment.yml)       β”‚
β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Argo CD (Operator)     β”‚
β”‚ GitOps Sync Controller β”‚
β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Kubernetes Cluster β”‚
β”‚ Spring Boot App β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ§ͺ Jenkins Pipeline Explanation

❓ How does your CI/CD pipeline work?

The pipeline follows a release-based CI model with GitOps-driven CD, ensuring traceability, versioning, and automated Kubernetes deployments.


πŸ”Ή Stage 1: Prepare Workspace

  • Cleans Jenkins workspace
  • Performs fresh SCM checkout

Why?

  • Prevents stale artifacts
  • Ensures reproducible builds

πŸ”Ή Stage 2: Create Release Branch

  • Jenkins creates release-<version> branch
  • Pushes branch to GitHub using stored credentials

Why?

  • Each release is immutable and traceable
  • Enables safe rollback

πŸ”Ή Stage 3: Build & Test (Dockerized Maven)

  • Uses official maven Docker image
  • Builds Spring Boot JAR
  • Stashes artifact for later stages

Why?

  • Tool isolation
  • No dependency on Jenkins host setup

πŸ”Ή Stage 4: Docker Image Build & Push

  • Unstashes JAR
  • Builds Docker image
  • Tags image with release version
  • Pushes image to Docker Hub

Why?

  • Immutable versioned images
  • Environment consistency

πŸ”Ή Stage 5: Update Deployment Repository

  • Jenkins updates deployment.yml
  • Replaces image tag with release version
  • Commits changes to deployment repository

Why?

  • Git becomes the single source of truth
  • Enables GitOps

πŸ”Ή Stage 6: Continuous Deployment with Argo CD

  • Argo CD watches deployment repo
  • Detects Git changes
  • Syncs Kubernetes automatically

Why?

  • No direct kubectl apply
  • Safe, auditable deployments

πŸ” Release Flow Documentation

Example Release Version: 1.0.1


1️⃣ Trigger Jenkins Pipeline

  • Manual trigger or Git push
  • Provide parameter: RELEASE_VERSION=1.0.1

2️⃣ Jenkins CI Actions

  • Creates branch: release-1.0.1
  • Builds JAR
  • Builds Docker image: saurabh3034/spring-voldemort:1.0.1
  • Pushes image to Docker Hub

3️⃣ Deployment Repository Update

Before: image: saurabh3034/spring-voldemort:replaceImageTag After: image: saurabh3034/spring-voldemort:1.0.1 Committed to: CI-CD_implementation/main

4️⃣ Argo CD Sync

  • Detects Git commit
  • Syncs Kubernetes manifests
  • Performs rolling update

5️⃣ Kubernetes Deployment

  • Old pods terminated
  • New pods created
  • Zero or minimal downtime

πŸ”™ Rollback Strategy

βœ… Git Revert (Recommended): git revert <commit-id>

  • Argo CD automatically rolls back the deployment.

βœ… Image Rollback:

  • Change image tag to previous version and commit.

πŸ” Security & Best Practices

  • Jenkins credentials store for secrets
  • No hardcoded tokens
  • Dockerized build environments
  • GitOps-based deployment control
  • Immutable artifacts

🧠 One-Line Summary

β€œI implemented a Jenkins-based CI pipeline with GitOps-driven CD using Argo CD, enabling secure, versioned, and fully automated Kubernetes deployments.”

βœ… Outcome

  • Every release triggers:
    • Create Release branch
    • New Docker image build
    • Push Docker image on DockerHub
    • Updated Kubernetes manifests
    • Automatic deployment via Argo CD

🧠 Key Concepts Covered

  • Branch Strategy
  • Artifact sharing in Jenkins (stash / unstash)
  • Secure GitHub authentication
  • Multi-repository CI/CD
  • GitOps using Argo CD
  • Operator-based Argo CD installation

πŸ“Œ Future Improvements

  • Helm charts
  • Image scanning (Trivy)
  • Manual approval gates
  • Slack notifications
  • Ingress with TLS

About

This repository demonstrates an end-to-end CI/CD pipeline using Jenkins, Docker, GitHub, Kubernetes and Argo CD (Operator-based).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors