Skip to main content
Contact our team to know more about our services
select webform
By submitting, you acknowledge that you've read and agree to our privacy policies, and Opcito may use the information provided for business purposes.
Become a part of our team
select webform
One file only.
1.5 GB limit.
Allowed types: gif, jpg, jpeg, png, bmp, eps, tif, pict, psd, txt, rtf, html, odf, pdf, doc, docx, ppt, pptx, xls, xlsx, xml, avi, mov, mp3, mp4, ogg, wav, bz2, dmg, gz, jar, rar, sit, svg, tar, zip.
By submitting, you acknowledge that you've read and agree to our privacy policies, and Opcito may use the information provided for business purposes.
Compose to Kubernetes simplified with Kompose
10 Aug 2021

Compose to Kubernetes simplified with Kompose

Containers started their journey way back in the late 70s. However, application containerization really started gaining momentum at the beginning of the last decade, and it has been up since then. With the advent of Docker and Kubernetes, most of us started deploying and scaling on distributed platforms using containers. Once the application is containerized, then arises the big question of what next? There are some easy-to-go options. Docker Swarm is used while deploying a cluster of Docker nodes with multiple hosts for a scalable application. Docker Compose is used while deploying multiple containers to a single host through a simple YAML file. Kubernetes is used when you need to manage a large deployment of automated, scalable containers. If your containers are within the same host, then there is nothing like Docker Compose. However, if you are networking containers across multiple hosts, then Kubernetes is the way. One significant difference is that Docker Compose runs on a single host, whereas Kubernetes usually uses multiple nodes, which can be added or removed dynamically.

So, if your requirement suggests going with Kubernetes, then go with it. But what if you already have the Docker Compose? Well, this blog is your way out. You need to translate your Compose service definitions to Kubernetes objects to run your services on a distributed platform like Kubernetes. And Kompose is a conversion tool that can help you out here.

Why Kompose?

Kompose supports the conversion of Docker Compose files into Kubernetes and OpenShift objects. Not only this, there are some highlighting advantages that you get with Kompose, such as:

  • It allows you to select multiple Docker Compose files at the same time.
  • The configuration gets merged due to multiple Docker-Compose files. Kompose aids in overriding the standard configurations by the subsequent file.
  • Kompose supports creating build config for building directives in a service. By default, it makes use of the remote repo for the current git branch as the source repo and the current branch as the source branch for the build. It enables you to specify a different source repo and branch using build-repo and build-branch options, respectively.
  • The default transformations in Kompose generate Kubernetes deployments and services in YAML format. However, you'll be having an alternative option to generate JSON with -j.
  • It allows us to alternatively generate Helm charts, Daemon Sets, and Replication Controllers objects.

How to get started with Kompose?

The procedure to install Kompose is pretty straightforward. Before you start, make sure you have the Kubernetes cluster in a running state, and you must configure the kubectl command-line to communicate with your cluster. If you don't have a cluster, you can create it with the help of minikube. It is important to note that, Kompose supports converting versions 1, 2, and 3 of Docker Compose into Kubernetes and OpenShift objects.

Now let’s see the actual process to install Kompose:

  • Sample docker-compose file for WordPress application

    Sample docker-compose file for WordPress application
  • Use kompose convert to create Kubernetes manifest file from the above docker-compose file.

    Kompose convert

    It will create manifest files, as shown in the above image.

  • Use kubectl apply -f <file name> to do the deployment

    kubectl apply -f

    To deploy the same thing on OpenShift, use kompose --provider openshift convert.

    To deploy on the Kubernetes cluster, use kompose up.

  • You can specify an alternative option to generate json with -j
  • If you want to create a chart to be used with Helm run, use kompose convert -c

    kompose convert - c
  • tree docker-compose

    tree docker-compose

Kompose supports two providers: Kubernetes and OpenShift. You can select the desired provider using the global option --provider. If the provider isn't specified, Kubernetes is selected as a default option.

There are several alternatives to Kompose, such as Helm, Rancher, Swarm, Portainer, Fargate, Mirantis, etc. The list is huge. However, if you consider switching from Docker Compose to Kubernetes, then Kompose is your best bid as there are barely any direct competitors. The only prerequisite is sufficient knowledge of Kubernetes, its resources, and the container ecosystem around it. Try the above process and let me know your experience. Talk to our experts to know more about how Kompose can make your Compose to Kubernetes journey easier.

Subscribe to our feed

select webform