<p>My YAML file has the following environment variables defined.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: codingjediweb
spec:
  replicas: 2
  selector:
    matchLabels:
      app: codingjediweb
  template:
    metadata:
      labels:
        app: codingjediweb
    spec:
      volumes:
      - name: shared-logs
        emptyDir: {}
      containers:
      - name: codingjediweb
        image: docker.io/manuchadha25/codingjediweb:06072020
        volumeMounts:
        - name: shared-logs
          mountPath: /deploy/codingjediweb-1.0/logs/
        env:
            - name: db.cassandraUri
              value: cassandra://xx.yy.zzz.ppp:9042
            - name: db.password
              value: 9__
            - name: db.keyspaceName
              value: dbname
            - name: db.username
              value: dbname2
       ports:
        - containerPort: 9000
      - name: logging
        image: busybox
        volumeMounts:
        - name: shared-logs
          mountPath: /deploy/codingjediweb-1.0/logs/
        command: ['sh', '-c', &quot;while true; do sleep 86400; done&quot;]
</code></pre>
<p>My Play application uses the variables. If a variable is not defined in the config file then Play checks for environment variables.</p>
<p><a href="https://www.playframework.com/documentation/2.6.x/ConfigFile" rel="nofollow noreferrer">https://www.playframework.com/documentation/2.6.x/ConfigFile</a></p>
<p>My application picks the configuration as follows:</p>
<pre class="lang-scala prettyprint-override"><code> val dbUsernameOption = configuration.getOptional[String](&quot;db.username&quot;)

    val dbUsername = dbUsernameOption.map(name =&gt; name).getOrElse({
      cassandraRepositoryComponentsLogger.error(&quot;unable to pick db username from configuration.&quot;)
      &quot;&quot;
    })

    val dbPasswordOption = configuration.getOptional[String](&quot;db.password&quot;)
    val dbPassword = dbPasswordOption.map(name=&gt;name).getOrElse({
      cassandraRepositoryComponentsLogger.error(&quot;unable to pick db password from configuration.&quot;)
      &quot;&quot;
    })
</code></pre>
<p>When I start the application by applying the Kubernetes YAML file, the container stops and I see an error</p>
<pre><code>unable to pick db username from configuration.
unable to pick db password from configuration.
</code></pre>
<p>I can see that the environment variables are defined in the container.</p>
<pre class="lang-sh prettyprint-override"><code># printenv
db.keyspaceName=somename &lt;-- here
KUBERNETES_PORT=tcp://10.15.240.1:443
KUBERNETES_SERVICE_PORT=443
CODINGJEDIWEB_SERVICE_PORT_9000_TCP_ADDR=10.15.249.26
HOSTNAME=codingjediweb-649db4fcb9-xxhwm
CODINGJEDIWEB_SERVICE_PORT_9000_TCP_PORT=9000
SHLVL=1
CODINGJEDIWEB_SERVICE_PORT_9000_TCP_PROTO=tcp
HOME=/root
CODINGJEDIWEB_SERVICE_SERVICE_HOST=10.15.249.26
db.cassandraUri=cassandra://xxx &lt;-- here
CODINGJEDIWEB_SERVICE_PORT_9000_TCP=tcp://10.15.249.26:9000
CODINGJEDIWEB_SERVICE_SERVICE_PORT=9000
CODINGJEDIWEB_SERVICE_PORT=tcp://10.15.249.26:9000
db.username=something &lt;-- here
TERM=xterm
KUBERNETES_PORT_443_TCP_ADDR=10.15.240.1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_PORT_443_TCP=tcp://10.15.240.1:443
KUBERNETES_SERVICE_HOST=10.15.240.1
PWD=/
db.password=9__ &lt;-- here
/ #
</code></pre>
<p>Am I incorrect that Play will check for environment variables if the configuration is missing in the config file? I am not sure if this is a Play issue or a Kubernetes issue because when I run the Play application in IntelliJ and provide the environment variables in the build configuration then the application works.</p>
<p><a href="https://i.stack.imgur.com/lm2fX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lm2fX.png" alt="IntelliJ" /></a></p>

Manu Chadha
<p>My guess is that those are JVM environment variables and bash/shell environment variables, hence they are not being picked up.</p>
<p>One option from the K8s perspective is to make your whole config file a <a href="https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/" rel="nofollow noreferrer">Secret</a> and the mount it under <code>conf/application.conf</code></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Secret
metadata:
  name: appconf-secret
data:
  application.conf: |
     ...
     ...
     ...
</code></pre>
<p>Then:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: codingjediweb
spec:
  replicas: 2
  selector:
    matchLabels:
      app: codingjediweb
  template:
    metadata:
      labels:
        app: codingjediweb
    spec:
      volumes:
      - name: shared-logs
        emptyDir: {}
      - name: appconf
        secret:
          secretName: appconf-secret
      containers:
      - name: codingjediweb
        image: docker.io/manuchadha25/codingjediweb:06072020
        volumeMounts:
        - name: shared-logs
          mountPath: /deploy/codingjediweb-1.0/logs/
        - name: appconf
          mountPath: /deploy/codingjediweb-1.0/conf/application.conf
      ...
</code></pre>
<p>Another approach is to use your original approach and use <a href="https://www.playframework.com/documentation/2.6.x/ConfigFile#Substitutions" rel="nofollow noreferrer">Substitutions</a> in your Play config file.</p>
