A complete CI/CD pipeline implementation demonstrating automated testing, containerization, and Kubernetes deployment using industry-standard DevOps tools.
This project showcases a professional CI/CD workflow that automatically builds, tests, and deploys a Node.js application to a Kubernetes cluster whenever code changes are pushed to the repository.
- Application: Node.js with Express
- Testing: Mocha and chai or Supertest
- Containerization: Docker
- Container Registry: Docker Hub
- Orchestration: Kubernetes
- CI/CD: Jenkins
- Version Control: Git
The Jenkins pipeline automatically:
- ✅ Runs unit tests with Mocha/Supertest
- ✅ Builds and pushes Docker images to Docker Hub
- ✅ Deploys the application to Kubernetes cluster
Git Repository → Jenkins Pipeline → Docker Build → Docker Hub → Kubernetes Deployment
- Jenkins (installed locally or containerized)
- Docker & Docker Hub account
- Kubernetes cluster (local via Docker Desktop or cloud)
- Node.js & npm
- Docker Desktop: Enable Kubernetes in Docker Desktop settings
- CLI Tools: Install kubectl and Helm via package managers:
# Using Chocolatey choco install kubernetes-cli kubernetes-helm # Using Winget winget install Kubernetes.kubectl Helm.Helm
- Install required plugins: NodeJS, Docker, Kubernetes,Git, Docker, Docker pipeline
- Configure credentials:
- Git repository access
- Docker Hub registry
- Kubernetes cluster config
- Add your SonarQube credentials to Jenkins
- The Jenkinsfile already contains the integration code (currently commented)
- Uncomment the SonarQube stage in the pipeline for code quality analysis
For running Jenkins and SonarQube as Docker containers:
- Use the included
ngrok.yamlconfiguration - Exposes both Jenkins and SonarQube services publicly
- Perfect for development and testing environments
-
Clone the repository
git clone https://github.com/MohamedElaassal/k8s-CI_CD-app.git
-
Configure Jenkins Pipeline
- Create new pipeline job
- Point to repository Jenkinsfile
- Set up required credentials
-
Trigger Pipeline
- Push code changes to trigger automatic deployment
- Monitor pipeline execution in Jenkins dashboard
├── app.js # Main application
├── package.json # Dependencies
├── Dockerfile # Container configuration
├── Jenkinsfile # CI/CD pipeline
├── ngrok.yaml # ngrok configuration for containerized services
├── test/
│ └── appTest.js # Unit tests
└── k8s/
├── deploy.yaml # Kubernetes deployment
└── service.yaml # Kubernetes service
- Automated Testing: Unit tests run on every commit
- Container Security: Multi-stage Docker builds
- Scalable Deployment: Kubernetes orchestration
- SonarQube Ready: Code quality integration available
- Production Ready: Professional CI/CD practices
Deploy monitoring stack using Helm:
# Add Helm repositories
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
# Install Prometheus and Grafana
helm install prometheus prometheus-community/prometheus
helm install grafana grafana/grafanaThe application exposes Prometheus metrics at /metrics endpoint for monitoring.
This project demonstrates modern DevOps practices and can serve as a foundation for production-ready CI/CD implementations.