Using Ribbon-Kubernetes discovery with Zuul

7/19/2016

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?

-- phoenix7360
kubernetes
netflix-zuul
spring
spring-boot
spring-cloud

1 Answer

7/20/2016

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
-- phoenix7360
Source: StackOverflow