<p>I have a config map that was created from an application.properties file:</p>

<pre><code>apiVersion: v1
data:
  application.properties: |-
    datasource-url: xxx
    web-service-url: https://xxx
kind: ConfigMap
  name: my-configmap
  namespace: mynamespace
</code></pre>

<p>I would like to create environment variables from some of those values, e.g.:</p>

<pre><code>spec:
  containers:
    - name: test-container
      image: k8s.gcr.io/busybox
      command: [ "/bin/sh", "-c", "env" ]
      env:
        - name: SPECIAL_LEVEL_KEY
          valueFrom:
            configMapKeyRef:
              name: my-configmap
              key: datasource-url
</code></pre>

<p>However this doesn't work, it can't access the datasource-url property from the file.</p>

codependent
<p>in your case it won't work since you define data as <code>application.properties</code> file. It needs to be <code>key:value</code> maps, see <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-with-data-from-multiple-configmaps" rel="nofollow noreferrer">here</a></p>

<p>in your case: </p>

<pre><code>apiVersion: v1
data:
  datasource-url: xxx
  web-service-url: https://xxx
kind: ConfigMap
  name: my-configmap
  namespace: mynamespace
</code></pre>
