How to achieve hazelcast syncing in kubernetes with different pod (App and Hazel insatnce)?

7/23/2018

They should able to communicate and update should visible to each other i mean mainly syncing.

DiscoveryStrategyConfig strategyConfig = new DiscoveryStrategyConfig(factory); Blockquote

// strategyConfig.addProperty("service-dns", "my-serice-name.my-namespace.svc.cluster.local"); // strategyConfig.addProperty("service-dns-timeout", "300");

strategyConfig.addProperty("service-name", "my-service-name"); strategyConfig.addProperty("service-label-name", "my-service-label"); strategyConfig.addProperty("service-label-value", true); strategyConfig.addProperty("namespace", "my-namespace");

I have followed the https://github.com/hazelcast/hazelcast-kubernetes.I have used the first approach was able to see the instance(per pod not in one members list) but they were not communicating (if I am doing crud in one hazel instance it's not reflecting in other). I want to use DNS strategy but was not able to create the instance only.

-- Samrat Roy
hazelcast
kubernetes
kubernetes-ingress

1 Answer

7/27/2018

Please check the followings:

1. Discovery Strategy

For Kubernetes you need to use the HazelcastKubernetesDiscoveryStrategy class. It can be defined in the XML configuration or in the code (as in your case).

2. Labels

Check that the service for your Hazelcast cluster has the labels you specified. The same when it comes to the service name and namespace.

3. Configuration

There are two ways to configure the discovery: DNS Lookup and REST API. Each has special requirements. You mentioned DNS Lookup, but the configuration you've sent actually uses REST API.

DNS Lookup

Your Hazelcast cluster service must be headless ClusterIP.

    spec:
      type: ClusterIP
      clusterIP: None

REST API

You need to grant access for you app to access Kubernetes API. Please check: https://github.com/hazelcast/hazelcast-code-samples/blob/master/hazelcast-integration/kubernetes/rbac.yaml

Other helpful resources

-- RafaƂ Leszko
Source: StackOverflow