<p>I'm working on a Java Play project, and in my <code>application.conf</code> file I have a Redis cluster set-up that receives an array of Redis server nodes.</p>

<p>Now, I want to inject that value in Kubernetes deployment as an environment variable and can't find the right syntax to do so.</p>

<p>My current <code>application.conf</code> looks something like this:</p>

<pre><code>play.cache.redis {
  # enable cluster mode
  source: cluster

  # nodes are defined as a sequence of objects:
  cluster:  [
    {
      # required string, defining a host the node is running on
      host:        localhost
      # required integer, defining a port the node is running on
      port:        6379
      # optional string, defines a password to use
      password:    null
    }
  ]
}
</code></pre>

<p>Can someone please tell me how to pass the <code>play.cache.redis.cluster</code> variable to a Kubernetes deployment so it stays like this?</p>

<p>You can inject your entire application.conf with a mechanism of ConfigMaps:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metatada:
  name: app-config
data:
  application.conf: |
    play.cache.redis {
      # enable cluster mode
      source: cluster
      # nodes are defined as a sequence of objects:
      cluster:  [
        {
          # required string, defining a host the node is running on
          host:        localhost
          # required integer, defining a port the node is running on
          port:        6379
          # optional string, defines a password to use
          password:    null
        }
      ]
    }
</code></pre>

<p>and then mount it directly to your container:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: ....
spec:
  containers:
    - name: ...
      image: ...
      volumeMounts:
      - name: config-volume
        mountPath: /etc/config
  volumes:
    - name: config-volume
      configMap:
        name: app-config
</code></pre>

<p>The app can access it then at /etc/config/application.conf.</p>
