This repository demonstrates a full CI/CD pipeline for a Golang application, showing how code changes are built, containerized, and deployed to an OpenShift cluster using modern DevOps tools.
.
βββ app/ # Go application code & Dockerfile
β βββ main.go
β βββ go.mod
β βββ go.sum
β βββ Dockerfile
β
βββ k8s/helm-chart/ # Helm chart for OpenShift deployment
β βββ Chart.yaml
β βββ values.yaml
β βββ templates/
β βββ deployment.yaml
β βββ service.yaml
β βββ route.yaml
β
βββ Jenkinsfile # Jenkins CI/CD pipeline definition
The pipeline is orchestrated using Jenkins, triggered via GitHub Webhooks on commits to the main branch.
- Trigger: GitHub push event (via webhook).
- Build: Compiles the Go application as a static binary.
- Dockerize: Creates a lightweight image using a multi-stage Dockerfile.
- Push: Publishes the image to Docker Hub (
tusk03/golang-app).
- Login: Jenkins authenticates with OpenShift via CLI (
oc login) using a secret token. - Deploy: Runs
helm upgrade --installusing the chart ink8s/helm-chart/. - Expose: OpenShift
Routeexposes the service (similar to Ingress in Kubernetes).
| Tool/Platform | Purpose |
|---|---|
| Go (Golang) | Application logic |
| GitHub | Source control |
| Jenkins | CI/CD pipeline automation |
| Docker | Containerization of app |
| Docker Hub | Container registry |
| Helm | Kubernetes/OpenShift deployment |
| OpenShift | Container orchestration platform |
Building this pipeline involved solving several real-world DevOps issues:
- Error:
go.mod not found, orunable to prepare context. - Fix: Reorganized project so the Dockerfile and Go files live inside
/app. Updateddocker buildpath to./appinJenkinsfile.
- Error: Jenkins failed to push image to Docker Hub.
- Fix: Corrected
withCredentialsblock inJenkinsfileusingusernamePasswordfor DockerHub credentials.
- Error:
oc login: token invalid or expired. - Fix: Generated a fresh token from OpenShift Console and updated Jenkins credentials.
- Error:
Chart.yaml file is missing. - Fix: Corrected the path to
./k8s/helm-chartand ensured file is namedChart.yaml(case-sensitive).
By the end of this CI/CD pipeline:
- A new Go binary is compiled and containerized automatically.
- Docker image is pushed to your registry.
- Helm deploys the updated image to your OpenShift cluster using rolling upgrades.
- The app is available via a public OpenShift
Route.