<p>I am trying to deploy cloudsql proxy as sidecar contaier like this:</p>

<pre><code>        - name: cloudsql-proxy
          image: gcr.io/cloudsql-docker/gce-proxy:1.11
          command: ["/cloud_sql_proxy",
              "-instances=${CLOUDSQL_INSTANCE}=tcp:5432",
              "-credential_file=/secrets/cloudsql/google_application_credentials.json"]
          env:
            - name: CLOUDSQL_INSTANCE
              valueFrom:
                secretKeyRef:
                  name: persistence-cloudsql-instance-creds
                  key: instance_name
          volumeMounts:
            - name: my-secrets-volume
              mountPath: /secrets/cloudsql
              readOnly: true
</code></pre>

<p>But when I deploy this, I get following error in logs:</p>

<pre><code>2019/06/20 13:42:38 couldn't connect to "${CLOUDSQL_INSTANCE}": googleapi: Error 400: Missing parameter: project., required
</code></pre>

<p>How could I use environment variable in command that runs inside kubernetes container?</p>

Bunyk
<p>If you want to reference environment variables in the command you need to put them in <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#use-environment-variables-to-define-arguments" rel="noreferrer">parentheses</a>, something like: <code>$(CLOUDSQL_INSTANCE)</code>. </p>
