CI/CD Pipeline Explained with Real-Life Example (Jenkins + GitHub + Docker + K8s)
In DevOps, CI/CD pipelines are the heartbeat of modern software delivery. They automate everything from code commit to deployment. In this blog, Iβll explain what CI/CD means and walk you through a real-world pipeline using tools like GitHub, Jenkins, Docker, and Kubernetes.
π What is CI/CD?
- CI (Continuous Integration) β Automatically builds and tests every code change pushed to version control.
- CD (Continuous Delivery or Deployment) β Automatically delivers or deploys code to production once it passes all stages.
Together, CI/CD eliminates manual effort and accelerates software delivery.
π Why CI/CD Matters in DevOps
- Reduces human errors
- Enables fast feedback for developers
- Supports agile teams with continuous updates
- Improves code quality through automated testing
π CI vs CD: The Difference
Continuous Integration (CI) | Continuous Delivery/Deployment (CD) |
---|---|
Code integration + testing | Deployment to staging or prod |
Focuses on code quality | Focuses on release automation |
Tools: Jenkins, GitHub Actions | Tools: Spinnaker, ArgoCD, Helm |
π§ͺ Real-Life CI/CD Pipeline Example
Hereβs a simplified but real example of how I set up CI/CD using Jenkins + GitHub + Docker + Kubernetes in a client project:
π§ Tools Used:
- GitHub β Code repo
- Jenkins β CI/CD automation server
- Docker β Containerization
- Docker Hub β Image registry
- Kubernetes (EKS) β Container orchestration
𧬠Pipeline Steps:
- Code Push: Developer pushes code to
main
branch on GitHub. - Jenkins Trigger: Jenkins pipeline is triggered using GitHub webhook.
- Build & Test:
- Code is pulled from GitHub
- Unit tests run
- App is built using Maven or npm
- Dockerize:
- Docker image is built
- Image is tagged with the commit ID
- Pushed to Docker Hub
- Deploy to Kubernetes:
- Jenkins uses
kubectl
to apply updated YAML files - New version of the app is deployed to Kubernetes cluster (EKS)
- Jenkins uses
π‘ Example Jenkinsfile:
pipeline {
agent any
stages {
stage('Clone') {
steps {
git 'https://github.com/your-org/your-app.git'
}
}
stage('Build') {
steps {
sh 'npm install' // or mvn clean install
}
}
stage('Docker Build & Push') {
steps {
sh '''
docker build -t yourname/app:$BUILD_NUMBER .
docker push yourname/app:$BUILD_NUMBER
'''
}
}
stage('Deploy to K8s') {
steps {
sh 'kubectl apply -f k8s/deployment.yaml'
}
}
}
}
π¦ Popular CI/CD Tools You Can Explore
- Jenkins β Flexible and powerful
- GitHub Actions β Easy setup within GitHub
- GitLab CI β Great for GitLab users
- ArgoCD β GitOps-style continuous deployment to Kubernetes
- CircleCI β Cloud-native and developer-friendly
π§ Conclusion
Implementing CI/CD might look complex at first, but once it’s in place, it changes how teams deliver software. Start simple with GitHub + Jenkins, and scale by adding Docker and Kubernetes. Automate gradually and iterate as your projects grow.