How Can I Access My Redis Cluster in Kubernetes Using NodePorts?

0
8
Asked By TechieTurtle42 On

Hey everyone! I'm hoping someone can help me with a bit of a challenge I'm facing. I've set up a Redis cluster on my Kubernetes environment, which runs on three bare-metal cloud servers. Initially, I tried using Docker directly, but encountered latency issues when accessing it from the outside.

Now, I've moved everything to Kubernetes and created a StatefulSet with three pods for my Redis masters. I manually set up the cluster using the `redis-cli --cluster create` command and everything's functioning well internally.

The tricky part is, I need to access this Redis cluster from an external source—specifically, a Python app utilizing the `redis-py` client. Since we're on bare metal and can't use LoadBalancer services, I've set up NodePort services to expose the Redis pods.

However, when I attempt to connect from outside, I run into issues because the Redis cluster is advertising the internal Pod IPs that my client cannot reach. I even tried to set up the cluster with NodePort IPs and ports, but that's not working either as Redis needs to bind and advertise IPs it controls.

I've also looked into the Bitnami and official Helm charts, but they don't seem to support NodePorts, as they only offer LoadBalancer or ClusterIP setups, which isn't suitable for my scenario.

So, I'm really wondering: Is there a reasonable way to run a Redis cluster in Kubernetes and access it externally through NodePorts, or should I consider managing Redis outside of Kubernetes? Any tips or experiences from anyone who's navigated this would be greatly appreciated!

1 Answer

Answered By CloudNinja99 On

You can definitely connect to a NodePort Service from outside your cluster by using the Node's IP along with the assigned NodePort. Just ensure you're following the right connection protocol, like TCP. Here's the link to the Kubernetes documentation for more clarity: kubernetes.io/docs/concepts/services-networking/service/#type-nodeport. What you need is something like `:` to connect.

CodeWizard88 -

I had a similar issue where I could reach individual nodes but struggled to connect to the cluster. It happened because the cluster was giving out Pod IPs of the other Redis nodes, which my setup couldn't access externally.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.