I have a Redis Cluster (3 master and 3 slaves) running inside a Kubernetes cluster. The cluster is exposed via a Kubenetes-Service (Kube-Service).
I have my application server connected to the Redis Cluster (using the Kube-Service as the URI) via the Lettuce java client for Redis. I also have the following client options set on the Lettuce connection object:
ClusterTopologyRefreshOptions topologyRefreshOptions = ClusterTopologyRefreshOptions.builder()
.enablePeriodicRefresh(Duration.ofMinutes(10))
.enableAllAdaptiveRefreshTriggers()
.build();
ClusterClientOptions clusterClientOptions = ClusterClientOptions.builder()
.topologyRefreshOptions(topologyRefreshOptions)
.autoReconnect(true)
.disconnectedBehavior(ClientOptions.DisconnectedBehavior.REJECT_COMMANDS)
.build();
redisClient.setOptions(clusterClientOptions);
Now when I test this setup by killing one of my Redis master's (pods), Kubernetes does its job by re-scheduling a new pod. But the new pod has a new IP address and it is never discovered by Lettuce. How does Lettuce handle re-discovery. It seems like the logic above for topology refresh does not do a DNS lookup again for the new IPs.
Is there any samples out there or anyone who have handled this. I have read multiple Github issues on Lettuce itself that doesn't give a clear way as to how it was handled.
Best