Kong / charts

Helm chart for Kong
Apache License 2.0
249 stars 480 forks source link

KONG_HEADERS env var true/false boolean flag is invalid #356

Closed MyMirelHub closed 3 years ago

MyMirelHub commented 3 years ago

Problem Setting an environment variable field to off in the helm chart, gets translated to false which is breaking the deployment.

What I expect to happen According to the configuration docs, boolean values of both off and false should be accepted and not beak the config.

Steps to reproduce

In the chart values.yaml I am setting the HEADERS field from https://github.com/Kong/kong/blob/master/kong.conf.default to off

kong:
  env:  
      "HEADERS": "off"

The chart then translates this to false in the deployment which sends the pod in a crash loop

      - env:
        - name: KONG_ADMIN_ACCESS_LOG
          value: /dev/stdout
        - name: KONG_ADMIN_ERROR_LOG
          value: /dev/stderr
        - name: KONG_ADMIN_GUI_ACCESS_LOG
          value: /dev/stdout
        - name: KONG_ADMIN_GUI_ERROR_LOG
          value: /dev/stderr
        - name: KONG_ADMIN_LISTEN
          value: 127.0.0.1:8444 http2 ssl
        - name: KONG_CLUSTER_LISTEN
          value: "off"
        - name: KONG_DATABASE
          value: "off"
        - name: KONG_KIC
          value: "on"
        - name: KONG_HEADERS
          value: "false"

kubectl get pods

kong-release     1/3     CrashLoopBackOff   14         11m

Additional details

Editing the deployment yaml in k8s directly kubectl edit kong.yaml and setting it to off fixes it.

- env:
        - name: KONG_HEADERS
          value: "off"

Kong chart version 2.1.0, Kong app version 2.4

ichasco-heytrade commented 3 years ago

Hi, I have the same error but it only fails in kong-kong-pre-upgrade-migrations job

time="2021-05-10T14:10:30Z" level=info msg="spawning process: [/bin/sh -c kong migrations up]"
Error: headers: invalid entry 'false'

  Run with --v (verbose) or --vv (debug) for more details

Config:

...
env:
    headers: off
...

Thanks!

rainest commented 3 years ago

Yeah, YAML's helpful boolean aliases often aren't that helpful, unfortunately. You'll just need to quote it:

$ cat /tmp/headers.yaml 
env:
  headers: off

$ cat /tmp/headers_quotes.yaml 
env:
  headers: "off"

$ helm template ex kong/kong -f /tmp/headers.yaml | grep -A1 KONG_HEADE       
        - name: KONG_HEADERS
          value: "false"

$ helm template ex kong/kong -f /tmp/headers_quotes.yaml | grep -A1 KONG_HEADE                   
        - name: KONG_HEADERS
          value: "off"

off/false are equivalent in most kong.conf settings, but headers is handled a bit differently because Kong doesn't actually store it as a boolean--it's a string instead to handle the other possible settings (e.g. server_tokens). The usual rule doesn't work for it as such.