A containerized Node.js microservice orchestrated with an 8-stage Jenkins declarative pipeline, deploying to a Kubernetes (K8s) cluster.
- App Stack: Node.js, Express, MongoDB.
- Infrastructure: Docker, Kubernetes (Dual-namespace: Staging/Production).
- CI/CD: Jenkins (Groovy DSL).
- Security & Quality: Snyk, Mocha, Supertest, npm audit.
The pipeline is designed with a "Shift-Left" philosophy, ensuring security and quality are validated before any infrastructure is provisioned.
- Build: Resolves dependencies using
npm installand primes the workspace. - Test: Executes integration tests using Mocha/Supertest to catch logic errors early.
- Code Quality: Runs
npm auditto verify dependency health and identify code smells. - Security: Scans for high-severity vulnerabilities using Snyk CLI.
- Package: Builds an immutable Docker image with unique branch-build tagging and pushes to Docker Hub.
- Deploy to Staging: Automated deployment to the
stagingnamespace viakubectlfor QA verification. - Release Promotion: A manual approval gate on the
mainbranch that promotes the verified build toproductionand performs Automated Git Tagging (e.g.,v1.0.15). - Monitoring: A resilience stage that polls the K8s
/healthendpoint to verify the MongoDB handshake and logs live telemetry.
- Cluster Visibility: Integrated with Headlamp for real-time pod metrics, logs, and resource tracking.
- Automated Alerting: A global
postblock sends Rich HTML Email Notifications upon build success or failure, including live telemetry snippets. - Self-Healing Verification: Uses
kubectl rollout statusto ensure deployments are fully functional before marking a build as successful.
- Jenkins with Docker and Kubernetes CLI plugins installed.
- A running Kubernetes cluster (e.g., Minikube or MicroK8s).
- Snyk API Token and Docker Hub credentials configured in Jenkins.
- Finnhub Stock API
- Clone this repository.
- Configure the following Credentials in Jenkins:
docker-hub-creds: Docker Hub Username/Password.finnhub-api-key: Finnhub Stock API Secret.github-leo-token: GitHub PAT for automated tagging.k8s-node-ip-secret: k8s node ip address.
- Create a Multibranch Pipeline job pointing to this repository.
- Run the pipeline to initiate the first build.