<p>Imagine I got a Kubernetes cluster which has 3 pods and each pod has its own value for the label 'name' and what I actually want is each time I run/open my app, I'd see the name of pod (so its label's value) on console output. 
Of course the output/value may be different each time, based on which pod is being used. </p>

<p>So, Is there any way to access the value of a pod label of the application (pod) running from code? </p>

<p>My app is based on Java (Spring Boot) by the way.</p>

<p>Thanks.</p>

<p>You can use Kubernete's <a href="http://kubernetes.io/docs/user-guide/downward-api/" rel="nofollow">Downward API</a> to Convey Pod Properties to the containers inside the pods without having to use Kubernete's REST API. From the docs:</p>

<blockquote>
  <p>It is sometimes useful for a container to have information about itself, but we want to be careful not to over-couple containers to Kubernetes. The downward API allows containers to consume information about themselves or the system and expose that information how they want it, without necessarily coupling to the Kubernetes client or REST API.</p>
</blockquote>
