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 --install
using the chart ink8s/helm-chart/
. - Expose: OpenShift
Route
exposes 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 build
path to./app
inJenkinsfile
.
- Error: Jenkins failed to push image to Docker Hub.
- Fix: Corrected
withCredentials
block inJenkinsfile
usingusernamePassword
for 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-chart
and 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
.