This project is a simple C++ HTTP API with one endpoint:
GET /health->{"status":"ok"}
It demonstrates:
- Build with
make+gcc - Unit tests with
google test - Coverage with
gcov - Containerization with Docker
- Kubernetes deployment to
alpha,beta,prod - Jenkins pipeline with environment stages
g++/gccmakegcov- Google Test headers/libs (
gtest) - Docker Desktop running
kindkubectl
Install Google Test:
# Ubuntu/Debian
sudo apt-get update && sudo apt-get install -y libgtest-dev cmake
# macOS (Homebrew)
brew install googletestmake all
./build/health_apiIn another shell:
curl -i http://localhost:8080/healthmake test
./scripts/run_coverage.shCoverage gate in scripts/run_coverage.sh requires at least 80% line coverage.
make docker-build
make docker-run
make docker-test
make docker-stopThis project includes scripts and make targets to stand up a complete local pipeline environment.
Start stack:
make local-ci-upThis creates:
- kind cluster:
jenkins-kube - local registry:
localhost:5001 - Jenkins container:
http://localhost:8081
Get Jenkins admin password:
make local-ci-passwordSet up a dedicated Jenkins agent (recommended):
- In Jenkins UI:
Manage Jenkins->Nodes->New Node- Name:
local-agent - Type:
Permanent Agent - Remote root directory:
/home/jenkins/agent - Labels:
local-agent - Launch method:
Launch agent by connecting it to the controller - Save and copy the generated secret from the node page
- Start agent container from this repo:
JENKINS_SECRET=<copied-secret> make jenkins-agent-up
- Pipeline now runs on this agent label (
local-agent) instead of the Jenkins controller.
Stop and remove everything:
make local-ci-downStop agent only:
make jenkins-agent-downIf make local-ci-up fails with a kind kubelet/control-plane timeout:
- Ensure Docker Desktop is running and has at least 4 CPUs and 6+ GB memory.
- Retry with pinned node image (already defaulted in script):
make local-ci-down KIND_NODE_IMAGE=kindest/node:v1.30.8 make local-ci-up
- Open Jenkins at
http://localhost:8081. - Install suggested plugins.
- Create a Pipeline job.
- Point it to this repo and use Jenkinsfile.
- Run with defaults:
IMAGE_REPO=localhost:5001/health-apiK8S_CONTEXT=kind-jenkins-kube
Pipeline stages run Alpha -> Beta -> Prod. Each stage:
- builds (
make all) - runs tests (
make test) - runs coverage gate (
./scripts/run_coverage.sh) - builds and pushes image to local registry
- deploys Kubernetes manifest and waits for rollout
Manifests are in k8s/:
k8s/alpha.yaml-> namespacehealth-alphak8s/beta.yaml-> namespacehealth-betak8s/prod.yaml-> namespacehealth-prod
Image names are injected at deploy time by Jenkins by replacing REPLACE_IMAGE.