<p>I'm currently building an API for Firebase Admin SDK and I want to store the Admin SDK credential file as a secret in Kubernetes.</p>
<p>This is an example from google on how to use the credential file:</p>
<pre><code>var admin = require(&quot;firebase-admin&quot;);

var serviceAccount = require(&quot;path/to/serviceAccountKey.json&quot;);

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: &quot;https://test.firebaseio.com&quot;
});
</code></pre>
<p>the credentials are in serviceAccountKey.json.</p>
<p>this is what the content of the file looks like:</p>
<pre><code>{
  &quot;type&quot;: &quot;service_account&quot;,
  &quot;project_id&quot;: &quot;test&quot;,
  &quot;private_key_id&quot;: &quot;3455dj555599993n5d425j878999339393po6&quot;,
  &quot;private_key&quot;: &quot;-----BEGIN PRIVATE KEY-----\lkjsfdjlsjfsjflksjfklsjkljklfsjfksjkdjskljflk;sjflskjfklsjdljhijshdkjfhsjfhjsb2223b3==\n-----END PRIVATE KEY-----\n&quot;,
  &quot;client_email&quot;: &quot;firebase-adminsdk@test.iam.gserviceaccount.com&quot;,
  &quot;client_id&quot;: &quot;123334444555556665478884&quot;,
  &quot;auth_uri&quot;: &quot;https://accounts.google.com/o/oauth2/auth&quot;,
  &quot;token_uri&quot;: &quot;https://oauth2.googleapis.com/token&quot;,
  &quot;auth_provider_x509_cert_url&quot;: &quot;https://www.googleapis.com/oauth2/v1/certs&quot;,
  &quot;client_x509_cert_url&quot;: &quot;https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk%40test.iam.gserviceaccount.com&quot;
}
</code></pre>
<p>I already have this file I use for my other secrets:</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: paisecret
type: Opaque
stringData:
    MONGODB_PASSWORD: &quot;sjldkjsjdfklsl&quot;
    MONGODB_USERNAME: &quot;prod_user&quot;
    MONGODB_HOST: &quot;test.azure.mongodb.net&quot;
</code></pre>
<p>I'll like to add <code>serviceAccountKey.json</code> or its content to the secret file above and if possible I'll like to access it within the API like this: process.env.FIREBASE_ADMIN</p>

<p>If the question is just how to include it as a string in the Secret, you could simply add it as a multiline string.</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: paisecret
type: Opaque
stringData:
    MONGODB_PASSWORD: &quot;sjldkjsjdfklsl&quot;
    MONGODB_USERNAME: &quot;prod_user&quot;
    MONGODB_HOST: &quot;test.azure.mongodb.net&quot;
    FIREBASE_ADMIN: &gt;
      {
        &quot;type&quot;: &quot;service_account&quot;,
        &quot;project_id&quot;: &quot;test&quot;,
        &quot;private_key_id&quot;: &quot;3455dj555599993n5d425j878999339393po6&quot;,
        &quot;private_key&quot;: &quot;-----BEGIN PRIVATE KEY-----\lkjsfdjlsjfsjflksjfklsjkljklfsjfksjkdjskljflk;sjflskjfklsjdljhijshdkjfhsjfhjsb2223b3==\n-----END PRIVATE KEY-----\n&quot;,
        &quot;client_email&quot;: &quot;firebase-adminsdk@test.iam.gserviceaccount.com&quot;,
        &quot;client_id&quot;: &quot;123334444555556665478884&quot;,
        &quot;auth_uri&quot;: &quot;https://accounts.google.com/o/oauth2/auth&quot;,
        &quot;token_uri&quot;: &quot;https://oauth2.googleapis.com/token&quot;,
        &quot;auth_provider_x509_cert_url&quot;: &quot;https://www.googleapis.com/oauth2/v1/certs&quot;,
        &quot;client_x509_cert_url&quot;: &quot;https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk%40test.iam.gserviceaccount.com&quot;
      }
</code></pre>
