-1

Until now, our solution ran on three containers on the same IP. One of the containers had Redis. When the other two containers (communicating via message passing on Redis) needed to reach the Redis, they simply utilized port 6379. Since the Redis had the same machine/IP this was simple and straight forward.

  1. Now there is a need to run these three dockers on Kuberenetes and each docker container is now getting its own unique IP address. How does one manage that correctly?

  2. What if additional Redis containers are needed. How does each container knows which one to couple with?

AturSams
  • 7,568
  • 18
  • 64
  • 98
  • All three containers are within the same pod or on different pods? – Ronak Jain Dec 15 '22 at 12:45
  • Hi, I would like them to be in the same pod and the other team wants to have them in three different pods and I don't see the added value. Currently, I'm trying to construct an argument and meanwhile asking how we could make it work with three pods. – AturSams Dec 15 '22 at 15:05
  • I usually prefer container and pod to have a one-to-one mapping, it makes debugging easy - most benefits are summed in the linked answer. As for how will three pods will communicate is with the use of service instead of IP. https://stackoverflow.com/questions/61650478/what-are-the-dis-advantages-of-putting-multiple-containers-in-a-pod – Ronak Jain Dec 15 '22 at 17:50
  • If you want help on how to setup Service, I'll add an answer with an example. – Ronak Jain Dec 15 '22 at 17:54

1 Answers1

1

When switching to Kubernetes, you have to rely on the K8s architecture itself and think in a cloud-native manner. Consider that a pod is ephemeral: its IP will, potentially and eventually, change, anytime. You can not rely on a pod's IP.

What you can do is create a service (a clusterIP works great for this use case) that will serve as the entry point for every replicas of your Redis pod. The replicas should rely on the service, and K8s will take care of updating the list of : backing the service.

You can find a great tutorial of doing this here.

Gregorio Palamà
  • 1,965
  • 2
  • 17
  • 22