Home > Software design >  How to convert a docker-compose file to Kubernetes YAML file?
How to convert a docker-compose file to Kubernetes YAML file?

Time:06-29

How to convert the following code for docker-compose to Kubernetes YAML file.

version: '3.8'
services:
  mongo:
    image: mongo
    restart: always
    ports:
      - 27017:27017
    volumes:
      - ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro

CodePudding user response:

You will need several components, firstly, a service, that will get the http request. Then a Deployment to create the actual pod, if you need volume so also a Persistent Volume. In my repository you can find docker compose yaml converted to k8s. Of course, you will probably need to change some data.

CodePudding user response:

The kompose project is a project that provides a tool that does specifically this -- converts a docker-compose file into a set of Kubernetes yaml files. It might be worth a look for you.

For simple docker-compose files like this it would work fine. But for more complicated ones, it might over-complicate things, so YMMV and all.

  • Related