<p>I was trying to use embedded mode Hazelcast in Kubernetes env. However, I found that the nodes did not form a cluster. I am confused that if the code I use is incorrect or there is something I ignored.
My application.yaml goes as follows:</p>
<pre><code>mode: embedded
embedded:
  port: 16701
  kubernetes:
    enabled: true
    serviceDns: hazelcast-service.default.svc.cluster.local
</code></pre>
<p>And the method I configured my embedded Hazelcast goes as follows:</p>
<pre><code>Config config = new Config();
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getKubernetesConfig().setEnabled(true)
  .setProperty(&quot;service-dns&quot;, &quot;hazelcast-service.default.svc.cluster.local&quot;);
</code></pre>
<p>I followed the README in this <a href="https://github.com/hazelcast/hazelcast-kubernetes/" rel="nofollow noreferrer">Hazelcast Discovery Plugin for Kubernetes</a></p>
<p>Also, even though I follow the above GitHub instruction, I found that the piece of code I posted does not come from <em>hazelcast-kubernetes</em> dependencies, <em>hazelcast-all</em> instead.</p>

Joe Jack
<p>Without enabling diagnostics or even having the console output it's hard to say with 100% certainty; however, it appears you are attempting to use port: 16701 and hazelcast is still using 5701 since the resource file is after the hazelcast jar file in your classpath. Please ensure your yaml file is the first entry in the classpath and try again. The hazelcast jar file contains a default configuration file so it's important that it is not first in the classpath.</p>
