Connection Refused error when connecting to Kubernetes Redis Service

445 views
Skip to first unread message

Bhavna Gupta

unread,
Mar 14, 2023, 10:48:59 AM3/14/23
to Redis DB
Hi all,

I have installed Redis helm chart  v17.8.0 and app version  7.0.8 on aws instance. I am able to do telnet but not curl. Response for the curl gives response: curl: (52) Empty reply from server.

$ kubectl get po -o wide | grep redis
redis-master-0                                1/1     Running        worker8     
redis-replicas-0                               1/1     Running        worker3   
redis-replicas-1                               1/1     Running        worker1   
redis-replicas-2                               1/1     Running         worker5

$ kubectl get svc | grep redis

redis-headless              ClusterIP   None                    <none>        6379/TCP                              redis-master                  NodePort   10.233.1.75      <none>        6379:30625/TCP             redis-replicas                NodePort    10.233.43.127   <none>        6379:30671/TCP     

$ telnet worker8 30625
Trying 40.0.0.242...
Connected to worker8.
Escape character is '^]'.

$ curl http://worker8:30625
curl: (52) Empty reply from server
                                            

If I open a shell inside the pod with kubectl exec -it <redis-pod-name> -- sh  and ping the database with redis-cli -a test ping. I receive a PONG, so it seems that the password (password) resolves and the db is up.

$ kubectl exec -it redis-master-0 -- sh
Output:
Defaulted container "redis" out of: redis, volume-permissions (init)
$ redis-cli
127.0.0.1:6379> auth password
OK
127.0.0.1:6379> ping
PONG

However, if I try to connect a pod java app to the redis db, I get below exception: 
"message":"Redis health check failed","flowInfo":"?","stacktrace":"org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool\n atorg.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector

app.properties: 

spring.redis.host=redis-master
spring.redis.port=6379
spring.redis.password=password
 
Does anyone have any idea about this kind of behaviour?

Best Regards,
Bhavna

Reply all
Reply to author
Forward
0 new messages