<p>In a Hazelcast based system, deployed on Kubernetes, using auto-discovery by <code>service-label</code>, I'm trying to get the <em>Pod name</em> that each node is deployed on. What I'm getting is indeed the pod name for the first node, but the <strong>service name</strong> for the second. For example, <code>octane-deployment-blue-123c44bfb-xyzab</code> (pod) and then <code>10-20-30-100.my-service.svc.cluster.local</code> (service).</p>

<p>I'm fetching the values by</p>

<pre><code>HazelcastInstance hazelcastInstance = getInstance();
Member localMember = hazelcastInstance.getCluster().getLocalMember();
String name = localMember.getSocketAddress().getAddress().getHostName();
</code></pre>

<p>It seems that the name is determined by the auto-discovery mechanism.</p>

<p>Any way of getting this value?</p>

Ido Gal
<p>The simple answer of how to get Pod name is to skip all the Hazelcast part and just get Pod name from the env variable <code>HOSTAME</code> or with the use of <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#the-downward-api" rel="nofollow noreferrer">Downward API</a> like this:</p>

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

<p>Saying that, its very weird that you receive service name by executing <code>localMember.getSocketAddress().getAddress().getHostName()</code>. Seems like a bug to me. You can raise an issue with the steps to reproduce here: <a href="https://github.com/hazelcast/hazelcast-kubernetes" rel="nofollow noreferrer">https://github.com/hazelcast/hazelcast-kubernetes</a></p>
