kubernetes kompose up Unsupported env_file key

7/25/2018

i am trying to migrate a docrized project to kubernetes, i have used Kompose to convert the project

kompose --file docker-compose.yml convert,

when i run kompose up after migrating the files i get this error

$ kompose up WARN Unsupported env_file key - ignoring FATA Error while deploying application: k.Transform failed: image key required within build parameters in order to build and push service 'drkiq'

.env file:

SECRET_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx WORKER_PROCESSES=1 LISTEN_ON=0.0.0.0:8000 DATABASE_URL=postgresql://drkiq:yourpassword@postgres:5432/drkiq?encoding=utf8&pool=5&timeout=5000 CACHE_URL=redis://redis:6379/0 JOB_WORKER_URL=redis://redis:6379/0

Dockerized project Link here!

any idea how to convert the .env file to a format that can be used with kubernetes kompose

Docker-compose file:

  postgres:
    image: postgres:9.4.5
    environment:
      POSTGRES_USER: drkiq
      POSTGRES_PASSWORD: yourpassword
    ports:
      - '5432:5432'
    volumes:
      - drkiq-postgres:/var/lib/postgresql/data

  redis:
    image: redis:3.0.5
    ports:
      - '6379:6379'
    volumes:
      - drkiq-redis:/var/lib/redis/data

  drkiq:
    build: .
    links:
      - postgres
      - redis
    volumes:
      - .:/drkiq
    ports:
      - '8000:8000'
    env_file:
      - .drkiq.env
  sidekiq:
    build: .
    command: bundle exec sidekiq -C config/sidekiq.yml
    links:
      - postgres
      - redis
    volumes:
      - .:/drkiq
    env_file:
      - .drkiq.env
-- zewOlF
compose
docker
docker-compose
kompose
kubernetes

1 Answer

7/26/2018

Kubernetes kompose supports env_file conversion from Docker Compose 3.x version as it's described in Conversion matrix.

In Kubernetes you can use ConfigMap to store your environment variables from env_file. For SECRET_TOKEN variable, you can use Secrets to hold your private and sensitive data.

You can also check other tools for conversion purpose like compose2kube or k8s-env-gen.

According to the attached Docker-composer file and the error during the conversion process, I can assume that you missed image key value for drkiq and sidekiq services:

Update: docker-compose.yml file

version: '2'

services:
  postgres:
    image: postgres:9.4.5
    environment:
      POSTGRES_USER: drkiq
      POSTGRES_PASSWORD: yourpassword
    ports:
      - '5432:5432'
    volumes:
      - drkiq-postgres:/var/lib/postgresql/data

  redis:
    image: redis:3.0.5
    ports:
      - '6379:6379'
    volumes:
      - drkiq-redis:/var/lib/redis/data

  drkiq:
    build: .
    image: drkiq:tag
    links:
      - postgres
      - redis
    volumes:
      - .:/drkiq
    ports:
      - '8000:8000'
    env_file:
      - .drkiq.env
  sidekiq:
    build: .
    command: bundle exec sidekiq -C config/sidekiq.yml
    image: sidekiq:tag
    links:
      - postgres
      - redis
    volumes:
      - .:/drkiq
    env_file:
      - .drkiq.env
-- mk_sta
Source: StackOverflow