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:
mode: embedded
embedded:
port: 16701
kubernetes:
enabled: true
serviceDns: hazelcast-service.default.svc.cluster.local
And the method I configured my embedded Hazelcast goes as follows:
Config config = new Config();
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getKubernetesConfig().setEnabled(true)
.setProperty("service-dns", "hazelcast-service.default.svc.cluster.local");
I followed the README in this Hazelcast Discovery Plugin for Kubernetes
Also, even though I follow the above GitHub instruction, I found that the piece of code I posted does not come from hazelcast-kubernetes dependencies, hazelcast-all instead.
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.