<p>I'm trying to use a key file in my Kubernetes application and I can't seem to find an example of this anywhere. I want to use Firebase authentication in my NodeJS backend. When running my application locally I was using the following</p>
<pre><code>admin.initializeApp({
  credential: admin.credential.cert(SERVICE_ACCOUNT_KEY_PATH),
});
</code></pre>
<p>My initial thought was to create a <code>secret</code> from a key file like</p>
<pre><code>$ gcloud container clusters get-credentials my-cluster --zone us-central1-c --project my-project
$ kubectl create secret generic service-account-key \
    --from-file=${SERVICE_ACCOUNT_KEY_PATH}
</code></pre>
<p>However, since I am creating a <code>secret</code> there is not a path for me to set my <code>SERVICE_ACCOUNT_KEY_PATH</code> to when running my application in a Kubernetes container. What is the correct method for doing this in Kubernetes?</p>

Jest Games
<p>you can save the <strong>serviceaccount</strong> file inside the <strong>secret</strong> and mount the secret into the deployment volume.</p>
<p>so the secret will be accessible to deployment's volume and your pod can access it.</p>
<p>for example :</p>
<pre><code>apiVersion: v1
kind: Deployment
metadata:
  name: mypod
spec:
  containers:
  - name: mypod
    image: nginx
    volumeMounts:
    - name: foo
      mountPath: &quot;/etc/foo&quot;
      readOnly: true
  volumes:
  - name: foo
    secret:
      secretName: mysecret
</code></pre>
<p>you can check out the :</p>
<p><a href="https://kubernetes.io/docs/concepts/configuration/secret/#use-case-pod-with-ssh-keys" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/secret/#use-case-pod-with-ssh-keys</a></p>
<p>another example : <a href="https://kubernetes.io/docs/concepts/configuration/secret/#use-case-dotfiles-in-a-secret-volume" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/secret/#use-case-dotfiles-in-a-secret-volume</a></p>
<p>so basic idea is to mount the secret into the volume of the deployment and it will be used by the code.</p>
