0

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

WesternGun
  • 11,303
  • 6
  • 88
  • 157

2 Answers2

0

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

Nataraj Medayhal
  • 980
  • 1
  • 2
  • 12
  • So you mean I should change configMap ref name, or the file name of yaml? I think changing yaml file name does not work. – WesternGun Sep 13 '22 at 10:14
  • Variable Key name used inside configmap are “appconfig.yml“ and “operatorconfig.yml“ this has to properly defined without “.” – Nataraj Medayhal Sep 13 '22 at 11:09
  • OK you mean I cannot include . in the file name, so I must remove file extension. But why `foo.properties` file works? Please check the link in the OP, I see `game.properties` used there. – WesternGun Sep 13 '22 at 12:47
  • 1
    Configmap can be created in four different ways. If you are using configmap map to load it as environment variables inside pod then the variable key name shouldn’t have “.” For other options of configmap you can have it. https://kubernetes.io/docs/concepts/configuration/configmap/ When environment option is used in that case inside container when referencing $appconfig.yml won’t work. The same error you are experiencing – Nataraj Medayhal Sep 13 '22 at 12:57
  • This is good info, thanks a lot. I will read that page and try to understand better. – WesternGun Sep 13 '22 at 13:36
0

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.

WesternGun
  • 11,303
  • 6
  • 88
  • 157