spotahome / redis-operator

Redis Operator creates/configures/manages high availability redis with sentinel automatic failover atop Kubernetes.
Apache License 2.0
1.49k stars 356 forks source link

Add Master and Slave services in addition to Sentinel Service #626

Closed hashemi-soroush closed 11 months ago

hashemi-soroush commented 1 year ago

Feature Request: Master and Slave services

Some famous Redis service providers allow clients to directly connect to Redis instead of using Sentinel for finding Redis instances, for example, Scalegrid and DigitalOcean. On the other hand, the Spotahome Redis operator only supports Sentinel clients, because it doesn't create Kubernetes Service for the Redis itself. If an organization decides to migrate from those to a Redis service operated by this operator, all clients must be changed to use Sentinel. This can add a heavy load to the migration and even possibly change the organization's mind.

proposed solution

We can add a single service that selects all Redis pods. But this might route write requests to Slave instances, resulting in data loss. Also, if we select only the Master instance, all requests (including the read requests) will be routed to the Master, resulting in poor resource utilization.

Since, at the time of routing using Kubernetes services, we can't determine whether a request is a write or a read one, in order to have better resource utilization, we might need to rely on the client to choose which type of instances it wants to send each request to. So, we need two services: one for the Master instance, and the other for all the Slave instances.

Since the role of each Redis pod is mentioned in its labels, we can simply use that label in the service pod selector.

github-actions[bot] commented 11 months ago

This issue is stale because it has been open for 45 days with no activity.