<p>I am a newbie to kubernetes and I have to implement kubernetes secrets for existing configmaps with passwords hardcorded.</p>

<p>I have 2 configmaps for each pod, 1 settings.yaml and other settings_override.yaml. I have to make override file read environment variables where I have kept base64 secrets. 
I have created secrets and can see them in pods after printenv. </p>

<p>Kindly suggest me how can I make my settings_override.yaml file read these environment secrets.</p>

<p>Note: if I just remove the key:value pair from settings_override.yaml file then it is picking value from settings.yaml but not from my env variable. </p>

<p>Settings and setting_override file for reference:</p>

<p><code>apiVersion: v1 
 data: setting.json: | { 
 "test": { 
 "testpswd": "test123",
 "testPort": "123", 
  }, 
 }</code></p>

<p><code>apiVersion: v1 
 data: setting_override.json: | { 
"test": { 
"testpswd": "test456", 
"testPort": "456", 
}, 
}</code></p>

Anu Thakur
<p>As per my knowledge what you're trying to accomplish is not possible in Kubernetes.</p>

<p>A general reminder: <code>Secrets</code> are for confidential data and <code>ConfigMaps</code> are for non-confidential data.</p>

<p>You can't import a <code>Secret</code> into a <code>ConfigMap</code> or vice versa.</p>

<p>You can however fill environment variables from a <code>Secret</code> (<code>secretKeyRef</code>) or a <code>ConfigMap</code> (<code>configMapKeyRef</code>) like this:</p>

<pre><code>    env:
    - name: FOO
      valueFrom:
        configMapKeyRef:
          name: nonconfidentialdatahere
          key: nonconfidentialdatahere
    - name: BAR
      valueFrom:
        secretKeyRef:
          name: confidentialdatahere
          key: confidentialdatahere
</code></pre>

<p>So I suggest you read the port from your <code>ConfigMap</code> and the password from your <code>Secret</code> into an environment variable in your pod/deployment declaration and then start whatever service you want by passing those environment variables.</p>
