Compose to Kubernetes simplified with Kompose

Opcito Technologies
3 min readAug 12, 2021

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 to override the standard configurations by the subsequent file.
  • Kompose supports creating buildconfig for build 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 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 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
  • Use kompose convert to create Kubernetes manifest file from the above docker-compose file.
  • It will create manifest files, as shown in the above image.
  • Use kubectl apply -f <file name> to do the deployment…read more.

--

--

Opcito Technologies

Product engineering experts specializing in DevOps, Containers, Cloud, Automation, Blockchain, Test Engineering, & Open Source Tech