kubernetes / kompose

Convert Compose to Kubernetes
http://kompose.io
Apache License 2.0
9.49k stars 747 forks source link

Support adding condition to compose depends_on / warn the user #1871

Open aitrics-ray opened 4 months ago

aitrics-ray commented 4 months ago

What would you like to be added?

I'm trying to convert docker compose via kompose.

version: "3.8"

networks:
  shared_network:
    driver: bridge

services:
  mysql:
    container_name: mysql
    platform: linux/amd64
    restart: unless-stopped
    image: 997245385850.dkr.ecr.ap-northeast-2.amazonaws.com/prod/mysql:8.0.36-debian-18a00bd
    expose:
      - 3306
    ports:
      - "3306:3306"
    volumes:
      - ${VOLUME_DIR}/volumes/mysql/:/var/lib/mysql/
      - ${VOLUME_DIR}/logs/mysql/:/var/log/mysql/
    healthcheck:
      test: [ "CMD", "./healthcheck.sh" ]
      interval: 3s
      timeout: 3s
      retries: 100
    networks:
      - shared_network

  backend-migration:
    container_name: backend-migration
    platform: linux/amd64
    deploy:
      restart_policy:
        condition: on-failure
        delay: 10s
        max_attempts: 3
    image: 997245385850.dkr.ecr.ap-northeast-2.amazonaws.com/prod/vc-backend:${VC_IMAGE_TAG}
    entrypoint: [ "sh", "-c", "make migrate" ]
    env_file:
      - ../common_env/vc-backend.env
      - envs/db-encrypt.env
    networks:
      - shared_network
    depends_on:
      mysql:
        condition: service_healthy

  backend:
    container_name: backend
    platform: linux/amd64
    restart: unless-stopped
    image: 997245385850.dkr.ecr.ap-northeast-2.amazonaws.com/prod/vc-backend:${VC_IMAGE_TAG}
    command: uvicorn app.application:app --host 0.0.0.0 --port 8080
    ports:
      - "8080:8080"
    environment:
      - OTEL_SERVICE_NAME=backend
      - VITALCARE_ENVIRONMENT=development
    env_file:
      - ../common_env/vc-backend.env
      - envs/vc-backend.env
      - envs/db-encrypt.env
      - envs/otel.env
    hostname: api.vitalcare.io
    volumes:
      - ${VOLUME_DIR}/logs/backend/:/data/vc-backend/logs/
      - ${VOLUME_DIR}/admin/:${VC_BACKEND_MOUNT_PATH}
    networks:
      - shared_network
    depends_on:
      backend-migration:
        condition: service_completed_successfully

When I run kompose convert, I get an error like this. FATA services.backend-migration.depends_on must be a list My guess is that it's because it's a condition, not a list. Is there a workaround?

Why is this needed?

There are some things that depend_on is not a List.

cdrage commented 3 months ago

We don't support condition at the moment, sorry :(

We'll have to implement this in the future.

cdrage commented 3 months ago

I've gone ahead and updated the title of this issue

k8s-triage-robot commented 2 weeks ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale