<p>I am trying to deploy Redis (by creating a Helm chart) as a StatefulSet in Kubernetes cluster. I am not creating another Redis image on top of Official Redis Docker image, rather I am just trying to use the defaults available in <a href="https://hub.docker.com/_/redis/" rel="nofollow noreferrer">Official Redis Docker image</a> and just provide my <code>redis.conf</code> and <code>requirepass</code> at runtime. </p>

<p>To provide <code>redis.conf</code>, I am using a ConfigMap and mounting it in <code>/config/redis.conf</code> in the container.</p>

<p>Now, I want to pass <code>--requirepass</code> option as <code>args</code> in Kubernetes as below:</p>

<pre><code>...
containers: [
  {
    name: redis,
    image: {
      repository: redis,
      tag: 5.0
    },
    imagePullPolicy: Always,
    workingDir: /data/,
    args: [ "/config/redis.conf", "--requirepass", "&lt;password&gt;" ],  # line of concern
    ports: [
      containerPort: 6379
    ],
    env: [
      {
        name: REDIS_AUTH,
        valueFrom: {
          secretKeyRef: {
            name: redis,
            key: password
          }
        }
      }
    ],
...
</code></pre>

<p>The following line fails:</p>

<pre><code>args: [ "/config/redis.conf", "--requirepass", "${REDIS_AUTH}" ]
</code></pre>

<p>and on the contrary, this works:</p>

<pre><code>args: [ "/config/redis.conf", "--requirepass", "$(REDIS_AUTH)" ]
</code></pre>

<p>Even though, <code>$()</code> syntax is for command substitution and <code>REDIS_AUTH</code> is an environment variable rather than an executable, how does it work and <code>${REDIS_AUTH}</code> does not? </p>

<p>This is a Kubernetes specific feature that if you want to expand an environment variable in <code>command</code> or <code>args</code> field then you've to use the <code>$()</code> syntax instead of <code>${}</code> syntax. </p>

<p>Check this link: <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#use-environment-variables-to-define-arguments" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#use-environment-variables-to-define-arguments</a></p>
