"yaml: did not find expected key" with basic example #50

Closed
opened 2023-02-06 20:43:46 +00:00 by vincentjourdon · 3 comments
vincentjourdon commented 2023-02-06 20:43:46 +00:00 (Migrated from github.com)

Hello,
When I try to convert basic example from https://github.com/metal3d/katenary/blob/master/examples/basic/docker-compose.yaml, I obtain "yaml: did not find expected key" even if the chart is generated.
I guess the pb comes from these lines
katenary.io/mapenv: |
DB_HOST: {{ .Release.Name }}-database
I saw that indentation matters but I tried the example out of the box
My katenary version : 2.0.0-beta2
My kompose version : 1.25.0 (a70f80cc)
BR
Vincent

Hello, When I try to convert basic example from https://github.com/metal3d/katenary/blob/master/examples/basic/docker-compose.yaml, I obtain "yaml: did not find expected key" even if the chart is generated. I guess the pb comes from these lines katenary.io/mapenv: | DB_HOST: {{ .Release.Name }}-database I saw that indentation matters but I tried the example out of the box My katenary version : 2.0.0-beta2 My kompose version : 1.25.0 (a70f80cc) BR Vincent

The problem is simply that you didn't encaplusate "{{ .Release.Name }}-database" with quotes. Brackets are valid JSON objects, and Katernary tries to load the "mapenv" label as YAML.
Try with:

version: "3"

# this example is absolutely not working, it's an example to see how it is converted
# by Katenary
services:
  webapp:
    image: php:7-apache
    environment:
      DB_HOST: database
    ports:
      - "8080:80"
    labels:
      # expose an ingress
      katenary.io/ingress: 80
      # DB_HOST is actually a service name
      katenary.io/mapenv: |
        DB_HOST: "{{ .Release.Name }}-database"
    depends_on:
      - database

  database:
    image: mariadb:10
    environment:
      MARIADB_ROOT_PASSWORD: foobar
      MARIADB_USER: foo
      MARIADB_PASSWORD: foo
      MARIADB_DATABASE: myapp
    labels:
      # because we don't provide "ports" or "expose", alert katenary
      # to use the mysql port for service declaration
      katenary.io/ports: 3306
The problem is simply that you didn't encaplusate `"{{ .Release.Name }}-database"` with quotes. Brackets are valid JSON objects, and Katernary tries to load the "mapenv" label as YAML. Try with: ```yaml version: "3" # this example is absolutely not working, it's an example to see how it is converted # by Katenary services: webapp: image: php:7-apache environment: DB_HOST: database ports: - "8080:80" labels: # expose an ingress katenary.io/ingress: 80 # DB_HOST is actually a service name katenary.io/mapenv: | DB_HOST: "{{ .Release.Name }}-database" depends_on: - database database: image: mariadb:10 environment: MARIADB_ROOT_PASSWORD: foobar MARIADB_USER: foo MARIADB_PASSWORD: foo MARIADB_DATABASE: myapp labels: # because we don't provide "ports" or "expose", alert katenary # to use the mysql port for service declaration katenary.io/ports: 3306 ```

I just see that it's my example which is wrong... I will fix!

I just see that it's my example which is wrong... I will fix!
vincentjourdon commented 2023-02-07 08:48:02 +00:00 (Migrated from github.com)

Thank you for your quick answer !

Thank you for your quick answer !
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Katenary/katenary#50
No description provided.