This article describes how to create a Gitlab CI/CD pipeline using gitlab-runner and docker as the build strategy in order to deploy microservices on Openshift.
On my previous articles I have explained how to create your own hosted gitlab instance and deploy a single CI/CD pipeline using gitlab-runner. The whole setup was based on containers, as a result the infrastructure needed can be deployed on Openshift as well.
The pipeline consists of three steps, housekeeping, staging and cleaning. It is based on the default example that gitlab provides and uses oc commands to communicate with Openshift. It is configured to be triggered only for develop branch and every time a new commit is added the build starts.
- The housekeeping step will remove every resource that has been created from a previous build.
- The staging step will build the microservices based on your Dockerfile instructions as the build strategy is set to docker.
- The cleaning task will remove the building pods that have been created from Openshift.
The housekeeping step is allowed to fail so that if no resources are found, the building step will continue its work.
You can see below a simple run of the pipeline.
You can find the code of the pipeline in the below repository: