WesternGun
WesternGun

Reputation: 12787

Kubernete / Openshift: Config map contains keys that are not valid environment variable names / xxx.yml is not a valid variable

Is this supported by Kubernete / Openshift 3? I use a yaml file after data: and got error from Openshift:

Config map app-config contains keys that are not valid environment variable names. Only config map keys with valid names will be added as environment variables.

enter image description here

And:

enter image description here

Strangely, it says operatorconfig.yml is not a valid variable, but it's not a variable, it's a file.

Before, it was operator-config.yml, but now after removing -, it still does not work.

The definition is like this:

  - apiVersion: v1
    kind: ConfigMap
    metadata:
      name: app-config
    data:
      appconfig.yml: |
        swarm:
          resource-adapters:
            resource-adapters:
              activemq-rar:
                config-properties:
                  ServerUrl:
                    value: {{ some_url }}
                  UserName:
                    value: {{ some_user }}
        anothercomponent:
          url: {{ some_url }}
      operatorconfig.yml: {{ APP_OPERATOR_CONFIG | to_nice_yaml(width=99999) | trim | to_yaml(width=99999) }}

Neither does appconfig.yml nor operatorconfig.yml works, none got their property values recognized by the service.

I noticed that if it's property file, or properties file without file extension, it works in the official page. Does this mean yaml is not supported?? https://docs.openshift.com/container-platform/3.11/dev_guide/configmaps.html

Upvotes: 0

Views: 666

Answers (2)

WesternGun
WesternGun

Reputation: 12787

At last I found out that in the previous version of app, we load the yaml file content with mountedVolume, then app read that yaml file from the volume, not by loading yaml content in config map as environment variables; seems it's not supported. But to mount to a volume, you need a config map. That's why it was done like this in the beginning; having a config map does not mean you need to load it as environment variables.

My conclusion is that files specified after "data:" can only be properties file; i.e., with each line of "key=value" format; yaml is not.

So I use QUARKUS_CONFIG_LOCATIONS environment variable to point to the mount volume yaml files, and it works.

Upvotes: 0

Nataraj Medayhal
Nataraj Medayhal

Reputation: 1221

Config map app-config contains keys that are not valid environment variable names

Above error denotes that ConfigMap used for a container inside pod is loaded as environment variables. its an issue with environment variable key name used. Variables with "." is not supported naming convention for environmental variables ex: test.var, operatorconfig.yml and appconfig.yml

Upvotes: 0

Related Questions