Shadov
Shadov

Reputation: 5591

Redis cluster with leader-follower on Kubernetes and Spring-Boot configuration

I use this redis-operator: https://ot-container-kit.github.io/redis-operator/

Situation on Kubernetes after deploy:

pod: redis-cluster-leader-0
pod: redis-cluster-follower-0
pod: redis-cluster-leader-1
pod: redis-cluster-follower-1
pod: redis-cluster-leader-2
pod: redis-cluster-follower-2
service: redis-cluster-leader
service: redis-cluster-follower

Now I'm not sure how I should configure this on Spring-Boot side. I've seen some answers saying I should list all nodes for spring.redis.cluster.nodes but it doesn't sound right to me, those services are there for a reason.

Possibilities I can think of:

  1. spring.redis.host=redis-cluster-leader - doesn't work, io.lettuce.core.RedisCommandExecutionException: MOVED 13927 10.54.37.8:6379
  2. spring.redis.cluster.nodes=redis-cluster-leader:6379,redis-cluster-follower:6379 - it works, but I'm not sure it's correct, I have errorstat_NOAUTH:count=1 and errorstat_MOVED:count=1 when I do INFO in redis-cli (they are password protected)
  3. listing all 6 nodes for spring.redis.cluster.nodes, definitely feels wrong to me

Option 2 works, but I'm not sure, mostly because of the errorstat. Also this configuration is clearly meant to list the nodes, but I'm not listing the nodes, just services. Spring thinks there are 2 nodes when there are in fact 6 nodes, not sure if it has any consequences.

When I randomly killed some pods (not all of them) it just stopped working with tons of errors on the application side - no route no host, timeouts etc.

Upvotes: 1

Views: 1650

Answers (1)

rga
rga

Reputation: 21

Have you tried using the headless service which the operator also creates? This made it work for me.

spring.redis.host=redis-cluster-leader-headless

Upvotes: 2

Related Questions