k8s-redis-ha
k8s-redis-ha copied to clipboard
Redis Service should always point to redis master
Hi,
would it be possible to create a mechanism, which would create a redis-master-server service which would always point only to the redis master?
I'm thinking about dynamic labels changing for each redis-server pod... only the master pod would have the redis-master: true
label and the redis-master-service would have set its selector to redis-master: true
This possibly looks like a good solution too https://stackoverflow.com/questions/29226725/how-should-applciation-using-active-passive-redundant-model-be-containerized-usi
We use haproxy with custom healthcheck for that. But this could probably be simply implemented as a shell script for readiness probe:
backend bk_redis
option tcp-check
tcp-check send PING\r\n
tcp-check expect string +PONG
tcp-check send info\ replication\r\n
tcp-check expect string role:master
tcp-check send QUIT\r\n
tcp-check expect string +OK