1
votes

I'm running a kubernetes cluster in which I am deploying a "cloud native hazelcast" following the instructions on the kubernetes-hazelcast github page. Once I have a number of hazelcast instances running, I try to connect a java client to one of the instances but for some reason the connection fails.

Some background

Using a kubernetes external endpoint I can connect to hazelcast from outside the kubernetes cluster. When I do a REST call with curl kubernetes-master:32469/hazelcast/rest/cluster, I get a correct response from hazelcast with it's cluster information. So I know my endpoint works.

The hazelcast-kubernetes deployment uses the hazelcast-kubernetes-bootstrapper which allows some configuration by setting environment variables with the replication controller, but I'm using all defaults. So my group and password are "someGroup" and "someSecret".

The java client

My Java client code is really straightforward:

ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setConnectionAttemptLimit(0);
clientConfig.getNetworkConfig().setConnectionTimeout(10000);
clientConfig.getNetworkConfig().setConnectionAttemptPeriod(2000);
clientConfig.getNetworkConfig().addAddress("kubernetes-master:32469");
clientConfig.getGroupConfig().setName("someGroup");
clientConfig.getGroupConfig().setPassword("someSecret")
HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);

When start my client this is the log output of the hazelcast container

2016-07-05 12:54:38.143  INFO 5 --- [thread-Acceptor] com.hazelcast.nio.tcp.SocketAcceptor     : [172.16.15.4]:5701 [someGroup] [3.5.2] Accepting socket connection from /172.16.29.0:54333
2016-07-05 12:54:38.143  INFO 5 --- [        cached4] c.h.nio.tcp.TcpIpConnectionManager       : [172.16.15.4]:5701 [someGroup] [3.5.2] Established socket connection between /172.16.15.4:5701
2016-07-05 12:54:38.157  INFO 5 --- [.IO.thread-in-1] c.h.nio.tcp.SocketClientMessageReader    : [172.16.15.4]:5701 [someGroup] [3.5.2] Unknown client type: <

And the console output of the client

jul 05, 2016 2:54:37 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_someGroup][3.6.2] is STARTING
jul 05, 2016 2:54:38 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_someGroup][3.6.2] is STARTED
jul 05, 2016 2:54:48 PM com.hazelcast.client.spi.impl.ClusterListenerSupport
WARNING: Unable to get alive cluster connection, try in 0 ms later, attempt 1 of 2147483647.
jul 05, 2016 2:54:58 PM com.hazelcast.client.spi.impl.ClusterListenerSupport
WARNING: Unable to get alive cluster connection, try in 0 ms later, attempt 2 of 2147483647.
jul 05, 2016 2:55:08 PM com.hazelcast.client.spi.impl.ClusterListenerSupport
etc...

The client just keeps trying to connect but no connection is ever established.

What am I missing?

So why won't my client connect to the hazelcast instance? Is it some configuration part I'm missing?

2
I haven't worked on kubernetes. But looking at the console logs, any specific reason to have different Hazelcast versions between Node and Client? Can you update both to be 3.6.4 the latest or just change the cluster to be 3.6.2 to match with client. - A.K.Desai
Ha, that's amazing. I didn't think that a newer client talking to an older server would be a problem. But that was it, matching the versions works. Many thanks. (If you post your comment as an answer I will upvote it) - Morss
Glad it worked. Yeah, 3.6.x has lot of configuration changes n bug fixes. - A.K.Desai
I would suggest to use official hazelcast discovery plugin for kubernetes github.com/hazelcast/hazelcast-kubernetes - Vik Gamov

2 Answers

2
votes

Not sure about the official kubernetes support, however Hazelcast has a kubernetes discovery plugin (based on the new discovery spi) that works on both, client and nodes: https://github.com/noctarius/hazelcast-kubernetes-discovery

1
votes

Looking at the console logs, you have different Hazelcast versions between Node and Client? Can you either update both to be 3.6.4 i.e., the latest or just change the cluster to be 3.6.2 to match with client. 3.6.x has many configuration changes and many bug fixes as well.