How to connect to redis-ha cluster in Kubernetes cluster?

2/21/2019

So I recently installed stable/redis-ha cluster (https://github.com/helm/charts/tree/master/stable/redis-ha) on my G-Cloud based kubernetes cluster. The cluster was installed as a "Headless Service" without a ClusterIP. There are 3 pods that make up this cluster one of which is elected master.

The cluster has installed with no issues and can be accessed via redis-cli from my local pc (after port-forwarding with kubectl).

The output from the cluster install provided me with DNS name for the cluster. Because the service is a headless I am using the following DNS Name

port_name.port_protocol.svc.namespace.svc.cluster.local (As specified by the documentation)

When attempting to connect I get the following error:

"redis.exceptions.ConnectionError: Error -2 connecting to port_name.port_protocol.svc.namespace.svc.cluster.local :6379. Name does not resolve."

This is not working.

Not sure what to do here. Any help would be greatly appreciated.

-- G. Jetson
cluster-computing
containers
kube-dns
kubernetes
redis

2 Answers

6/8/2019

Not sure if this is still relevant. Just enhance the chart similar to other charts to support NodePort, e.g. rabbitmq-ha so that you can use any node ip and configured node port if you want to access redis from outside the cluster.

-- step
Source: StackOverflow

2/21/2019

the DNS appears to be incorrect. it should be in the below format

<redis-service-name>.<namespace>.svc.cluster.local:6379

say, redis service name is redis and namespace is default then it should be
redis.default.svc.cluster.local:6379

you can also use pod dns, like below

<redis-pod-name>.<redis-service-name>.<namespace>.svc.cluster.local:6379

say, redis pod name is redis-0 and redis service name is redis and namespace is default then it should be
redis-0.redis.default.svc.cluster.local:6379

assuming the service port is same as container port and that is 6379

-- P Ekambaram
Source: StackOverflow