Copied from https://github.com/antirez/redis/issues/3009
Nodes should be able to automatically discover a live cluster on node startup based on a list of static hosts in the config (Only a small list should suffice, just for the initial connection).
Example:
In the config have something like:
cluster-hosts: hostname1:port1 hostname2:port2 hostname3:port3
And on startup the node will try to automatically join the cluster if its not already joined.
That will help a lot with adding new nodes to an existing clusters automatically such as in an auto-scaling group.
I am wondering could this be used in kubernetes as well if we have resource called statefulsets in use? https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/ In statefulsets each pod will get unique dns like redis-{0..N-1}.default.svc.cluster.local. Currently it is pretty difficult to build redis cluster in kubernetes which have automatical HA features. But if we could use that pod dns to automatically connect to cluster, it could help a lot i think.
Would there be any mechanism to notify clients when a node is added to the cluster? It's one thing for a node to manually/automatically join a node to a cluster, but another for the clients to learn about it. Currently, my clients periodically perform a CLUSTER NODES (SLOTS would also work) and compares the results with the current connections. If there's a mismatch, I have to force the library (ioredis in this case) to disconnect and reconnect to the cluster (that's the only option with ioredis).
I suspect that since the Redis protocol appears to be purely a request/response, that such an async notification to a regular client would not be possible. Perhaps using a subscription client and pre-defined "management" channel could be used for this and perhaps other notifications.
I'm happy to work on this. Could it be as simple as using the same DNS lookup mechanism in Sentinel source code? It already does DNS lookups at runtime.
https://github.com/antirez/redis/blob/cb51bb4320d2240001e8fc4a522d59fb28259703/src/sentinel.c#L545
https://github.com/antirez/redis/blob/cb51bb4320d2240001e8fc4a522d59fb28259703/src/sentinel.c#L3119
Most helpful comment
I am wondering could this be used in kubernetes as well if we have resource called statefulsets in use? https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/ In statefulsets each pod will get unique dns like redis-{0..N-1}.default.svc.cluster.local. Currently it is pretty difficult to build redis cluster in kubernetes which have automatical HA features. But if we could use that pod dns to automatically connect to cluster, it could help a lot i think.