Index
OpenShift auto-deployments (EXPERIMENTAL)
This is repository that builds Docker Image with all scripts needed to deploy to OpenShift from GitLab CI.
It basically consist of two stages: 1. Build stage where a Docker Image is built, 2. Deploy stage where a previously built Docker Image is run on OpenShift and exposed on hostname.
Build stage
The build script does:
1. Check if the repository has Dockerfile
,
2. If yes, use docker build
to build Docker Image,
3. If no, use herokuish to build
and package a buildpack based application,
4. Login to GitLab Container Registry,
5. Push build image to GitLab Container Registry.
Deploy stage
The deploy script does: 1. Create a new project if does not exist already, 2. Delete old application, 3. Create a new application with most recent Docker Image, 4. Expose route with given hostname for this application.
Requirements
- GitLab Runner using Docker or Kubernetes executor with privileged mode enabled,
- Service account for existing OpenShift cluster,
- DNS wildcard domain to host deployed applications.
Limitations
- Only public docker images can be deployed,
- There is no upgrades for OpenShift existing deployments,
- There is no ability to pass environment variables to deployed application,
- Currently we do not have a way to watch for deployment status and make sure that deployment did succeed,
- Currently we do not have a way to expose
mysql
,postgres
or other database services.
Troubleshooting
Ensure that you're using the Deployment
resource
instead of DeploymentConfiguration
in order for Deploy Boards to render correctly.
For more information, read the OpenShift docs
and GitLab issue #4584.
Examples
You can see existing working examples: 1. Ruby
How to contribute?
Simply fork this repository. As soon as you push your changes, the new docker image with all scripts will be build. You can then start using your own docker image hosted on your Container Registry.
How to use it?
Basically, configure Kubernetes Service in your project settings and
copy-paste this .gitlab-ci.yml
.
License
MIT, GitLab, 2016