<p>I have docker image containing  a nodejs app and I deployed it via kubernetes deployment and I have 3 pods. What I need is to pass the name of the each deployment to the related pods so this way I have a unique id for each deployment which is unique to only that deployment and all pods inside that deployment can consume that id.
Also this one did not help much:</p>

<p><a href="https://stackoverflow.com/questions/42274229/kubernetes-deployment-name-from-within-a-pod">Kubernetes deployment name from within a pod?</a></p>

<p>I know for the fact that I can do the following in :</p>

<pre><code>env:
  - name: unique id
    value: {{uuidv4}}
</code></pre>

<p>But I would rather the following:</p>

<pre><code>env:
  - name: deployment name
    value: a way to get the deployment name
</code></pre>

<p>Any idea if it is even achievable?</p>

Learner
<p>So from the Kubernetes deployment documentation, one use case is:</p>

<blockquote>
  <p>Declare the new state of the Pods by updating the PodTemplateSpec of
  the Deployment. A new ReplicaSet is created and the Deployment manages
  moving the Pods from the old ReplicaSet to the new one at a controlled
  rate. Each new ReplicaSet updates the revision of the Deployment.</p>
</blockquote>

<p>So knowing the deploying is not relevant unless you want to rollback. So what you need is to get the pods to see each other. In that case, you need a headless service.</p>

<p><a href="https://dev.to/kaoskater08/building-a-headless-service-in-kubernetes-3bk8" rel="nofollow noreferrer">https://dev.to/kaoskater08/building-a-headless-service-in-kubernetes-3bk8</a></p>

<p>There you can get the pod DNS and tag them in your Redis by IP or DNS</p>

<p>EDIT:</p>

<p>For getting the deployment, every pod has an env var called HOSTNAME, for example (in my environment):</p>

<pre><code>HOSTNAME=stella-api-8675fcf6df-rm2m7
</code></pre>

<p>Where stella-api is the current deployment name, stella-api-8675fcf6df is the current replica set and finally, stella-api-8675fcf6df-rm2m7 would be the pod specific id</p>

<p>Hope this helps.</p>
