redis cluster K8S connection redis cluster K8S connection kubernetes kubernetes

redis cluster K8S connection


I belive in all scenarios you just need to expose the service using kubernetes Service object of type:

  • Cluster IP ( in case you are consuming it inside the cluster )

  • NodePort ( for external access )

  • LoadBalancer ( in case of public access and if you are on cloud provider)

  • NodePort with external loadbalancer ( for public external access if you are on local infrastructure )

Dont need to worry about individual pods. The Service will take care of them.

Docs:

https://kubernetes.io/docs/concepts/services-networking/service/


I don't think you need any port redirection. You have to build an ingress controller upon your cluster though, i.e. nginx ingress controller

Then you just set up a single ingress service with exposed access, which will serve a cluster traffic.

Here is an example of Ingress Controller to Access cluster service:

apiVersion: extensions/v1beta1kind: Ingressmetadata:  name: redis-cluster-ing  annotations:    kubernetes.io/ingress.class: "nginx"spec:  rules:  - http:      paths:      - backend:          serviceName: redis-cluster          servicePort: 6379

You may check a step-by-step instruction