kubernetes / kompose

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

kompose --file production.yml -o my_kubectl convert panic: Health check must contain a command #1564

Closed scheung38 closed 1 year ago

scheung38 commented 1 year ago

This is my production.yml file

I do have healthcheck in django defined:

 healthcheck:
      interval: 60s
      timeout: 10s
      retries: 5
      start_period: 20s
      #test: curl -f http://10.8.38.101:8080/health/ping
      test: curl --fail http://localhost || exit 1

or I didn't define the proper URL?

version: "3.8"

services:
  django: # &django
    build:
      context: .
      dockerfile: ./compose/production/django/Dockerfile
    image: ${ACR_NAME}.azurecr.io/my_production_django:v0.0.1
    container_name: my_production_django

    # platform: linux/x86_64
    depends_on:
      - mongo
      # - elasticsearch
      # - kibana
      # - postgres
      # - redis

    env_file:
      - ./.envs/.production/.django
      # - ./.envs/.production/.postgres
      - ./.envs/.production/.mongodb

    ports:
      - "8000:8000"
      - "3000:3000"

    environment:
      - DB_HOST=mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}"
      - DJANGO_READ_DOT_ENV_FILE=true
      - COOKIE_SECURE=true
      - DEBUG=true

    command: /start
    stdin_open: true
    tty: true

    #    restart: 'no' # for debugging only

    # secrets:
    #   - regcred

    healthcheck:
      interval: 60s
      timeout: 10s
      retries: 5
      start_period: 20s
      test: curl -f http://10.8.38.101:8080/health/ping
    #   # test: curl -f http://10.8.62.177:8080/health/ping
    #   # test: curl --fail http://10.8.38.101 || exit 1
    #   test: curl --fail https://arthur-paf-dev-arthur-paf-dev-scheung38.cloud.okteto.net || exit 1

    labels:
      kompose.service.group: sidecar

      # for konvert but not for production.yml ##############
      # kompose.service.healthcheck.liveness.http_get_path: "/health/ping"
      # kompose.service.healthcheck.readiness.test: "CMD curl -f http://10.8.38.101:8080/health/ping"
      #######################################################
      kompose.service.healthcheck.liveness.http_get_port: 8080
      kompose.service.healthcheck.readiness.interval: 10s
      kompose.service.healthcheck.readiness.timeout: 10m
      kompose.service.healthcheck.readiness.retries: 5
      kompose.service.healthcheck.readiness.start_period: 30s

      kompose.image-pull-secret: "regcred" # "acr-secret"
      kompose.image-pull-policy: "IfNotPresent"

      # kompose.service.annotations.dev.okteto.com/auto-ingress: "true"
      # dev.okteto.com/private: "true"

  mongo:
    image: mongo  
    container_name: "mongo"
    restart: always
    env_file:
      - ./.envs/.production/.mongodb
    environment:
      - MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME}
      - MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD}
      - MONGO_INITDB_DATABASE=${MONGO_NAME}
      - MONGO_INITDB_USERNAME=${MONGO_USERNAME}
      - MONGO_INITDB_PASSWORD=${MONGO_PASSWORD}

    volumes:
      - production_mongodb_data:/data/db
    ports:
      - 27017:27017 # mongodb
      - 9216:9216 # mongodb-exporter

kompose --file production.yml -o my_kubectl convert

panic: Health check must contain a command

goroutine 1 [running]: github.com/kubernetes/kompose/pkg/transformer/kubernetes.configProbe({{0x0, 0x0, 0x0}, 0x258, 0xa, 0x5, 0x1e, 0x0, {0x0, 0x0}, ...}) github.com/kubernetes/kompose/pkg/transformer/kubernetes/podspec.go:289 +0x630 github.com/kubernetes/kompose/pkg/transformer/kubernetes.(Kubernetes).UpdateKubernetesObjects.func1(0x14000501328) github.com/kubernetes/kompose/pkg/transformer/kubernetes/k8sutils.go:539 +0x5d0 github.com/kubernetes/kompose/pkg/transformer/kubernetes.(Kubernetes).UpdateController(0x140002972c0, {0x1014f8798, 0x14000501200}, 0x1400069d800, 0x1400069d7f0) github.com/kubernetes/kompose/pkg/transformer/kubernetes/kubernetes.go:1569 +0x2c4 github.com/kubernetes/kompose/pkg/transformer/kubernetes.(Kubernetes).UpdateKubernetesObjects(0x140002972c0, {0x1400003a328, 0x6}, {{0x140003d0e68, 0x6}, {0x14000402aa0, 0x1c}, {0x140002cef80, 0x3b}, {0x140005e4400, ...}, ...}, ...) github.com/kubernetes/kompose/pkg/transformer/kubernetes/k8sutils.go:632 +0x66c github.com/kubernetes/kompose/pkg/transformer/kubernetes.(Kubernetes).Transform(0x140002972c0, {0x1400027f470, {0x1011bcf11, 0x7}, 0x1400027f0b0}, {0x0, 0x1, 0x0, 0x0, 0x1, ...}) github.com/kubernetes/kompose/pkg/transformer/kubernetes/kubernetes.go:1548 +0x9ac github.com/kubernetes/kompose/pkg/app.Convert({0x0, 0x1, 0x0, 0x0, 0x1, {0x0, 0x0}, {0x0, 0x0}, {0x1011bb7d7, ...}, ...}) github.com/kubernetes/kompose/pkg/app/app.go:226 +0x34c github.com/kubernetes/kompose/cmd.glob..func3(0x101bc8d60, {0x140002fd3c0, 0x0, 0x4}) github.com/kubernetes/kompose/cmd/convert.go:130 +0x4c github.com/spf13/cobra.(Command).execute(0x101bc8d60, {0x140002fd380, 0x4, 0x4}) github.com/spf13/cobra@v1.1.3/command.go:856 +0x640 github.com/spf13/cobra.(Command).ExecuteC(0x101bc8fe0) github.com/spf13/cobra@v1.1.3/command.go:960 +0x404 github.com/spf13/cobra.(*Command).Execute(...) github.com/spf13/cobra@v1.1.3/command.go:897 github.com/kubernetes/kompose/cmd.Execute(...) github.com/kubernetes/kompose/cmd/root.go:89 main.main() github.com/kubernetes/kompose/main.go:27 +0x30

kompose version 1.27.0 (HEAD)

Docker version

Client: Docker Engine - Community Version: 20.10.23 API version: 1.41 Go version: go1.19.5 Git commit: 715524332f Built: Wed Jan 18 20:42:16 2023 OS/Arch: darwin/arm64 Context: default Experimental: true

Server: Docker Desktop 4.16.2 (95914) Engine: Version: 20.10.22 API version: 1.41 (minimum version 1.12) Go version: go1.18.9 Git commit: 42c8b31 Built: Thu Dec 15 22:25:43 2022 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.6.14 GitCommit: 9ba4b250366a5ddde94bb7c9d1def331423aa323 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0

Lctrs commented 1 year ago

See https://github.com/docker/compose/issues/10155

k8s-triage-robot commented 1 year 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

AhmedGrati commented 1 year ago

@scheung38 Adding this attribute to the labels section should solve your problem:

kompose.service.healthcheck.readiness.test: curl -f http://10.8.38.101:8080/health/ping