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?

  • 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?

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.

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