This project demonstrates an automated CI/CD pipeline setup using ArgoCD for GitOps-based deployment and OpenShift's BuildConfig for building the Docker image on OpenShift. The application is deployed in two environments: bog-dev and bog-prd. All configurations, including namespaces, image build, and routes, are managed via Git without the use of webhooks.
java-app/
├── app-code/ # Application source code and Dockerfile
│ ├── src/
│ ├── Dockerfile
│ └── pom.xml
└── k8s-manifests/ # Kubernetes manifests for ArgoCD deployment
├── base/ # Base configuration used across environments
│ ├── deployment.yaml
│ ├── service.yaml
│ ├── imagestream.yaml
│ └── kustomization.yaml
│ └── mysql-deployment.yaml
│ └── mysql-pvc.yaml
│ └── mysql-secret.yaml
│ └── mysql-service.yaml
└── overlays/ # Environment-specific overlays
├── bog-dev/ # Dev overlay with namespace and image configs
│ ├── kustomization.yaml
│ ├── namespace.yaml
│ ├── buildconfig.yaml
│ └── route.yaml
└── bog-prd/ # Prod overlay with namespace and image configs
├── kustomization.yaml
├── namespace.yaml
├── buildconfig.yaml
└── route.yaml
└── argocd-applications/ # ArgoCD applications for each environment
├── argocd-application-dev.yaml
└── argocd-application-prd.yaml
- Fork or clone this repository.
- Push all application code and Kubernetes manifests to your own Git repository: https://github.com/george-cassar/java-app.git.
- The BuildConfig in
pipeline/buildconfig.yamlis used to build and push the Docker image. - This file does not use webhooks and allows manual or configuration-based triggering.
- Define common resources (
deployment.yaml,service.yaml, andimagestream.yaml) in thebasedirectory. - Create environment-specific overlays in
overlays/bog-devandoverlays/bog-prdfor each namespace and route.
The namespace.yaml files in each overlay ensure namespaces are created automatically by ArgoCD if they don't already exist.
In each overlay, set up Kustomize to dynamically reference the correct namespace and image path.
In argocd-applications/, the ArgoCD applications for bog-dev and bog-prd are defined to monitor and deploy the changes.
Apply the ArgoCD applications to your OpenShift cluster:
oc apply -f k8s-manifests/argocd-application-dev.yaml
oc apply -f k8s-manifests/argocd-application-prd.yamlSince no webhooks are used, trigger the build manually:
oc start-build java-app-build -n bog-dev
oc start-build java-app-build -n bog-prdArgoCD will automatically detect any updates in the Git repository and sync them to the OpenShift environment.
This setup automates building and deploying the application to multiple environments using ArgoCD for GitOps-based deployment and OpenShift's BuildConfig for the CI build process.