<p>I have a K8s config map that defines an ENVIRONMENT parameter.</p>

<p>That value is mounted as an environment variable on the deployment yaml using an excerpt in src/fabric8/deployment.yml:</p>

<pre><code>spec:
  template:
    spec:
      containers:
      - env:
        - name: "ENVIRONMENT"
          valueFrom:
              configMapKeyRef:
                  name: global-configmap
                  key: ENVIRONMENT
</code></pre>

<p>I would like to use that ENVIRONMENT env variable to configure the <code>spring.active.profiles</code> property.</p>

<p>Is it supported in some way by fabric8 maven plugin? If not, can you suggest some workaround?</p>

<p>One thing to note first is that the name given to the environment variable injected into the Pod and the key being used from the configmap don't have to match. So you could do:</p>

<pre><code>      - env:
        - name: SPRING_PROFILES_ACTIVE
          valueFrom:
              configMapKeyRef:
                  name: global-configmap
                  key: ENVIRONMENT
</code></pre>

<p>If ENVIRONMENT is a key within the configmap called <code>global-configmap</code>. If it's not then naturally you want to use whatever the key is that matches the value you're looking for (something like spring.profiles.active might be clearer if possible but from your description it sounds like you have an existing configmap called global-configmap with the key called ENVIRONMENT). I expect you'll need to call the environment variable (the name section) SPRING_PROFILES_ACTIVE because this will match to the property spring.profiles.active by <a href="https://github.com/spring-projects/spring-boot/wiki/Relaxed-Binding-2.0" rel="noreferrer">relaxed binding</a>.</p>

<p>Alternatively, you do have other options with the fabric8 maven plugin, which it seems you're using for generation. You could simply <a href="https://maven.fabric8.io/#how-do-i-define-an-environment-variable" rel="noreferrer">set an environment variable directly</a>  or set the spring.profiles.active value directly in your property file, <a href="https://maven.fabric8.io/#how-do-i-mount-a-config-file-from-a-configmap" rel="noreferrer">which you could mount as a configmap</a>.</p>
