Using kubernetes svc without select to access external redis server. How to ensure my pod hits master only?

6/9/2021

I am using Kubernetes services with custom endpoints to access external redis cluster.

But I can't know which one is master and I want to ensure it only forward incoming connections to reach a master.

Is there anything in Kubernetes I could use for checking nodes and to get master?

This is piece of code from haproxy that does the job I need

backend redis .... 
tcp-check send info\ replication\r\n 
tcp-check expect string role:master ...
-- Dino L.
kubernetes
kubernetes-service
redis

1 Answer

6/9/2021

If I understand correctly, you are looking for a native k8s solution to detect which of external redis nodes are master nodes and point traffic to them.

My answer is: There is no way to do it natively.

You need to use some custom solution (such as your haproxy) to achieve it.

-- Matt
Source: StackOverflow