Java CI/CD on Kubernetes, from commit to zero-downtime release
A Jenkins, SonarQube, Trivy, Harbor, Argo CD and Argo Rollouts platform on a local kind cluster. Four automated gates sit between a commit and production, and three deliberately broken commits were each stopped at the right one.
- Role
- Personal project
- Year
- 2026
- Stack
- Jenkins
- Kubernetes
- kind
- SonarQube
- Trivy
- Harbor
- Argo CD
- Argo Rollouts
- JMeter
- Jib
- Prometheus
- Grafana
- Helm
- Spring Boot
- Java 21
Problem
I wanted a delivery pipeline where a bad change cannot reach users, and where I could show that with evidence rather than claim it. Passing builds prove little, so the test of this project is what it rejects. It is also groundwork for a like-for-like Graviton (arm64) against x86 comparison on EKS, which is why every commit builds both architectures.
Constraints
- Runs on a laptop. One kind cluster with a control plane and two workers, and about 16 GB of RAM for Docker.
- No Docker daemon or privileged pods in the cluster. Builds run as ephemeral agent pods.
- Least privilege. The pipeline may not read secrets or change Rollout specs.
- No inbound address. A laptop cluster cannot receive webhooks.
- Reproducible. The same source should give the same image.
Approach
A push to main runs these stages in a Jenkins pod that has Maven, Trivy, kubectl and JMeter containers:
- Change guard. Builds are skipped unless
app/or theJenkinsfilechanged. - Unit tests and JaCoCo coverage.
- SonarQube analysis and quality gate, which requires at least 80 % coverage on new code.
- Jib builds amd64 and arm64 images as tarballs, with no Docker daemon.
- Trivy scans both images for fixable HIGH and CRITICAL findings, before anything is pushed.
- A multi-arch image is pushed to Harbor.
- The pipeline commits the new tag to
deploy/. Argo CD syncs it and Argo Rollouts creates a green preview. - JMeter loads the preview. The error rate must stay under 1 % and p95 under 500 ms.
- Promote or abort. Promotion switches the live Service to the new version. Abort leaves the old version serving.
Prometheus scrapes both versions during a release, and the Grafana dashboard and scrape config are deployed from Git the same way as the app.
Key decisions and trade-offs
- Jib instead of Dockerfiles. No daemon or privileged pod is needed, both architectures build from an x86 agent without emulation, and the output is reproducible. Three different release tags in Harbor resolve to one digest.
- Scan before publishing. Trivy and
cranecould not talk to a plain-HTTP registry token endpoint. Rather than add TLS only to scan, the pipeline scans one tarball per architecture and pushes only if both are clean. A vulnerable image never enters the registry, which is the better posture anyway. - Spring Boot 4 for the sample app. Boot 3.5 still carried two unfixed CRITICAL
spring-webmvcCVEs when I scanned it, and the fix only exists in Spring Framework 7. Trivy forced the upgrade. - The load test runs in the pipeline, not the cluster. The verdict, the HTML report and the promote or abort decision stay in one place.
- GitOps through the same repository. The pipeline commits the tag and Argo CD deploys it. A separate manifests repository would be cleaner at scale.
- Polling instead of webhooks. Jenkins polls about every five minutes because kind has no inbound address. It is the first thing I would change in a shared environment.
Results
Three deliberately broken commits, each taken from real builds:
| Build | Change | Stopped at | Evidence |
|---|---|---|---|
| #2 | Pinned a vulnerable Tomcat | Trivy | 14 findings (8 CRITICAL, 6 HIGH); push skipped |
| #3 | Added an untested class | Sonar gate | New-code coverage 44.7 % against 80 % |
| #11 | Added 800 ms to the heavy endpoint | JMeter gate | p95 806 ms against 500 ms; Rollout aborted |
In none of the three did the live version change.
On the healthy path:
- Zero-downtime promotion. 166 requests were sent to the live URL during a promotion. None failed, and clients saw exactly one version change.
- Load test on a healthy release (build #9). 21,033 requests, 0 errors and p95 of 5 ms, with 20 concurrent users for 60 seconds.
- Release time. About 6 minutes with warm node-local caches (build #21) and about 11 minutes cold (build #17). Maven dependencies went from 80 s to 26 s and Trivy's databases from 196 s to 2 s.
- Tests. 7 unit tests pass and SonarQube new-code coverage is 91.7 %.
What went wrong along the way
- Rebuild loops, twice. Jenkins polling cannot filter by path, so the pipeline's own tag commit retriggered a build. My first fix compared against the last successful build, which made a failed release retrigger itself indefinitely. It now compares against the previous build's commit. I wrote this up in a separate post.
- A promote that silently lacked permission.
kubectl patch --subresourceneedsgetas well aspatch, and the failure appeared only on the first real promotion. - Cold caches. A build landed on a node with an empty Trivy cache and timed out downloading about 1 GB of databases. I fixed it with a longer timeout, one scan per image and a cache warm-up script.
Not in scope
This is a single-developer lab. Credentials in helm-values/ are local defaults, there is no TLS, the caches are node-local, and a clean rebuild from an empty machine in one pass has not been rehearsed.
What I would do next
- Run the Graviton against x86 comparison on EKS with the same Rollout and JMeter profile, and compare throughput, latency, start-up and cost per million requests.
- Replace polling with webhooks, add TLS, sign images and move to an external secret store.
- Move the manifests to a separate GitOps repository and share build caches instead of keeping them per node.