Skip to main content
In this tutorial, we’ll walk through a complete CI/CD workflow that builds a Spring Boot application, runs tests, publishes a Docker image, and deploys it to a Kubernetes cluster using a Jenkins Pipeline. Our Git repo contains a Kubernetes manifest (k8s_deployment_service.yaml) defining both a Deployment and a Service.

Table of Contents


Jenkins Pipeline (Jenkinsfile)

This pipeline leverages Maven for build and test, Docker for image creation and pushing, and the Kubernetes CLI (kubectl) for deployment.

Kubernetes Deployment & Service Manifest

The k8s_deployment_service.yaml file defines:
  • A Deployment named devsecops with 2 replicas.
  • A Service of type NodePort exposing port 8080.
Ensure you replace the placeholder replace with your Docker image tag (siddharth67/numeric-app:${GIT_COMMIT}) before applying the manifest.

Deploying the Node.js Service

We need a backend service that our Spring Boot app will call. Deploy a pre-built Node.js service (siddharth67/node-service:v1) in the default namespace:
Expected output:
The Node.js service is now reachable at http://node-service:5000.

Numeric Spring Boot Application

Update your controller to call the Kubernetes service instead of localhost. Example:
Commit all changes to your main branch—Jenkins will automatically trigger the pipeline.

Verifying the Deployment

After the pipeline completes, verify both applications:
Sample output:
Access the Numeric application via NodePort:
  • http://<NODE_IP>:31933/Kubernetes DevSecOps
  • http://<NODE_IP>:31933/increment/7778
  • http://<NODE_IP>:31933/compare/44Less than 50
  • http://<NODE_IP>:31933/compare/95Greater than 50
Both services communicate seamlessly within the Kubernetes cluster.

Watch Video

Practice Lab