<p>I'm trying to expose some of the container info as env variables reading the values from the pod's spec.template.spec.containers[0].name which seems to be not working. What would be the apiSpec for referencing the container fields inside the deployment template.The deployment template is as follows: </p>

<pre><code>    apiVersion: apps/v1
    kind: Deployment
    metadata:
      creationTimestamp: null
      labels:
        run: nginx
      name: nginx
    spec:
      replicas: 2
      selector:
        matchLabels:
          run: nginx
              strategy: {}
       template:
         metadata:
           creationTimestamp: null
            labels:
             run: nginx
        spec:
          containers:
           - image: nginx
            name: nginx
              ports:
             - containerPort: 8000
             resources: {}
            env:
             - name: MY_CONTAINER_NAME
                valueFrom:
                  fieldRef:
                    fieldPath: spec.template.spec.containers[0].name
</code></pre>

<p>The Downward API enables you to expose the pod’s own metadata to the processes
running inside that pod. </p>

<p>Currently, it allows you to pass the following information to your containers:</p>

<ul>
<li>The pod’s name</li>
<li>The pod’s IP address</li>
<li>The namespace the pod belongs to</li>
<li>The name of the node the pod is running on</li>
<li>The name of the service account the pod is running under</li>
<li>The CPU and memory requests for each container</li>
<li>The CPU and memory limits for each container</li>
<li>The pod’s labels</li>
<li>The pod’s annotations</li>
</ul>

<p>And that's it. As you can see the container port is not part of this list.</p>

<p>In general, the metadata available through the Downward API is fairly limited. If you need more, you’ll need to obtain it from the Kubernetes API server directly which you can do either by using client libraries or by using an ambassador container.</p>
