<p>I'm using kubernetes and changed all my replication controllers to deployments (the new RC from k8s ).</p>

<p>I used to  Expose Pod Information of Containers Through Environment Variables as described in here:</p>

<p><a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/</a></p>

<p>So I used it like that:</p>

<pre><code>  - name: MY_POD_NAME
    valueFrom:
      fieldRef:
        fieldPath: metadata.name
</code></pre>

<p>and it was working, after changing to deployments looks like that metadata.name is not defined and I can not use this as an Environment Variables anymore.</p>

<p>Does anyone know if this functionality is still working on deployments?</p>

<p>This deploymned works for me. can you test this in your cluster?</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
  labels:
    k8s-app: nginx
    tier: network-tools
  namespace: default
spec:
  replicas: 1
  template:
    metadata:
      labels:
        k8s-app: nginx
    spec:      
      containers:
      - name: nginx       
        image: nginx        
        env: 
        - name: SSHD
          value: TURE
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace       
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name        
        ports:
        - containerPort: 80
</code></pre>
