<p>I have my python applications running in redhat open shift container, for logging purpose i want to print/get the pod name programatically in python, i have no idea how to do it can someone please help?</p>

Abhishek K M
<p>A simple way is to use the <a href="https://kubernetes.io/docs/concepts/workloads/pods/downward-api/" rel="nofollow noreferrer">Downward API</a>, pass the information you need as environment variables and read the variable from your process</p>
<p>Example:</p>
<pre><code>env:
- name: MY_NODE_NAME
  valueFrom:
    fieldRef:
      fieldPath: spec.nodeName
- name: MY_POD_NAME
  valueFrom:
    fieldRef:
      fieldPath: metadata.name
- name: MY_POD_NAMESPACE
  valueFrom:
    fieldRef:
      fieldPath: metadata.namespace
</code></pre>
<p>Available fields: <a href="https://kubernetes.io/docs/concepts/workloads/pods/downward-api/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/downward-api/</a></p>
