CI/CD Pipeline Explained with Real-Life Example (Jenkins + GitHub + Docker + K8s)

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 + testingDeployment to staging or prod
Focuses on code qualityFocuses on release automation
Tools: Jenkins, GitHub ActionsTools: 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:

  1. Code Push: Developer pushes code to main branch on GitHub.
  2. Jenkins Trigger: Jenkins pipeline is triggered using GitHub webhook.
  3. Build & Test:
    • Code is pulled from GitHub
    • Unit tests run
    • App is built using Maven or npm
  4. Dockerize:
    • Docker image is built
    • Image is tagged with the commit ID
    • Pushed to Docker Hub
  5. Deploy to Kubernetes:
    • Jenkins uses kubectl to apply updated YAML files
    • New version of the app is deployed to Kubernetes cluster (EKS)

πŸ’‘ 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.

Leave a Comment

Your email address will not be published. Required fields are marked *