Introduction to Kompose for Openshift
Kompose is a open source tool that uses “docker-compose” file to deploy on kubernetes. Openshift is also Kubernetes based and kompose team decided they can support Openshift too.
Let’s say we have project with multiple microsevices that needs to deploy on Openshift and they have docker-compose.yml and Dockerfile. How do we deploy on Openshift? Normally we have several options: We can use s2i tools and a github repository, image deployment, importing from openshift yaml file. But the catch here is: “We have to deploy each other separately”.
Kompose is just like a “docker-compose” tool for Openshift. You can deploy the docker-compose file.
kompose convert -f docker-compose.yaml --provider=openshift
This command brings up “-imagestream.yaml”, “-service.yaml”, “-deploymentconfig.yaml” files for each microservice. (If you have volume, it creates persistent volume claim too)
We can use these config files to deploy on Openshift easily. Before you deploy, you have to login to Openshift via “oc” tool.
kompose up --provider=openshift -f docker-compose.yml --build build-config --namespace=example-project
Our Project is deployed on Openshift now.
We don’t deal with project code yet so we create Image Stream to deploy images later on.
As a side note if you have “build” option in docker-compose file, kompose automatically detects remote git url to deploy automatically.
As you can see we have image stream ready, you can push images to Openshift docker registry to build your applications.