I managed to have ribbon dynamically discover instances in a k8s cluster using kubeflix and spring-cloud-kubernetes
This was when I manually used Ribbon to communicate between my microservices.
Zuul automatically uses Ribbon for the routes defined in its configuration.
Has anyone managed to enable Ribbon discovery for Zuul? I think I would need to override the instance of LoadBalancer for each of the routes. Any ideas how to do that?
That was actually quite easy. You only need to specify the NIWSServerListClassName, the k8s namespace and the k8s port name in the Ribbon configuration:
service-name:
ribbon:
NIWSServerListClassName: io.fabric8.kubeflix.ribbon.KubernetesServerList
KubernetesNamespace: uat
PortName: tcp80 #make sure you this matches the port name in the k8s service (kubectl describe svc service-name)Then the Zuul route can refer to the service:
zuul:
routes:
rm-data-store:
path: /foo/**
retryable: true
service-id: service-name