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
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.
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.