Kubernetes Load Balancing With Authentication Kubernetes Load Balancing With Authentication kubernetes kubernetes

Kubernetes Load Balancing With Authentication


Looks like you are running single master node Redis . if you are running the multiple Redis replicas then they must be running in sync or i think in cluster mode.

In cluster mode, Redis will clone the data across the multiple replicas.

you can read at : https://redis.io/topics/cluster-tutorial#redis-cluster-101

you can also read more about redis replication concepts: https://redislabs.com/redis-enterprise/technology/highly-available-redis/

Regarding load balancing requests it will be done by the K8s service but your service won't be knowing which is "right" (read)(slave) replica and which one is "read/write"(Master) replica of redis so there is another component come in picture known as Sentinel.

Sentinel always checks master and slave nodes and tries to stable the cluster of Redis if any failure occurs without human intervention.

if you are running HA Redis cluster it will replicate your data across multiple replicas and using the library your can first request to sentinel and it will give you master IP, where you can perform a write operation on other IPs, read operation.

simple python code

from redis.sentinel import Sentinelsentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1)sentinel.discover_master('mymaster')('127.0.0.1', 6379)sentinel.discover_slaves('mymaster')[('127.0.0.1', 6380)]

On the master node, you will be able to write the data and on slave you can only read the data and replication will be there at a place across all replicas.

You should have to check the replication first inside Redis, still as i am not sure how you have set up the Redis can't suggest much.