title: use k8s secret from nodejs application
body: <p>I've created the following sample program which I need to create secret values</p>
  <p>index.js</p>
  <pre><code>const express = require(&quot;express&quot;);
  const port = process.env.PORT || 3000;
  
  
  app = express();
  app.get('/', (req, res) =&gt; (
      res.send(&quot;hello from k8s&quot;))
  )
  
  app.listen(3000, function () {
      console.log(&quot;my secret ---&gt; &quot;, process.env.TOKEN1)
      console.log(&quot;server is listen to port&quot;, port)
  })
  </code></pre>
  <p>This is the secret.yaml</p>
  <pre><code>apiVersion: v1
  kind: Secret
  metadata:
    name: secert1
    namespace: trail
  type: Opaque
  data:
    TOKEN1: cmVhbGx5X3NlY3JldF92YWx1ZTE=
  </code></pre>
  <p>and this is how I connected between of them</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: app1
    namespace: trail
  spec:
    replicas: 1
    template:
      metadata:
        labels:
          app: app1
      spec:
        containers:
          - name: app1
            image: myimage
            imagePullPolicy: Always
            ports:
              - containerPort: 5000
            env:
              - name: myenv
                valueFrom:
                  secretKeyRef:
                    name: secert1
                    key: TOKEN1
  
  
  
  </code></pre>
  <p>When deploying the program I see in k8s logs</p>
  <pre><code>
  my secret ---&gt;  undefined
  server is listen to port 5000
  
  </code></pre>
  <p>What am I missing here ?
  in addition assume that I've more than 20 properties which I need to read from my app, is there a better way or just map each of the key value in the secret ?</p>