Eureka and Kubernetes

How can I setup something like eureka.client.serviceUri?

You have to have a Kubernetes service on top of the eureka pods/deployments which then will provide you a referable IP address and port number. And then use that referable address to look up the Eureka service, instead of “8761”.

To address further question about HA configuration of Eureka

You shouldn’t have more than one pod/replica of Eureka per k8s service (remember, pods are ephemeral, you need a referable IP address/domain name for eureka service registry). To achieve high availability (HA), spin up more k8s services with one pod in each.

  • Eureka service 1 –> a single pod
  • Eureka Service 2 –> another single pod
  • ..
  • ..
  • Eureka Service n –> another single pod

So, now you have referable IP/Domain name (IP of the k8s service) for each of your Eureka.. now it can register each other.

Feeling like it’s an overkill?
If all your services are in same kubernetes namespace you can achieve everything (well, almost everything, except client side load balancing) that eureka offers though k8s service + KubeDNS add-On. Read this article by Christian Posta

Edit

Instead of Services with one pod each, you can make use of StatefulSets as Stefan Ocke pointed out.

Like a Deployment, a StatefulSet manages Pods that are based on an
identical container spec. Unlike a Deployment, a StatefulSet maintains
a sticky identity for each of their Pods. These pods are created from
the same spec, but are not interchangeable: each has a persistent
identifier that it maintains across any rescheduling.

Leave a Comment