<p>I managed to have ribbon dynamically discover instances in a <code>k8s</code> cluster using <a href="https://github.com/fabric8io/kubeflix" rel="nofollow">kubeflix</a> and <a href="https://github.com/fabric8io/spring-cloud-kubernetes" rel="nofollow">spring-cloud-kubernetes</a></p>

<p>This was when I manually used <code>Ribbon</code> to communicate between my microservices.</p>

<p><code>Zuul</code> automatically uses <code>Ribbon</code> for the routes defined in its configuration.</p>

<p>Has anyone managed to enable <code>Ribbon</code> discovery for <code>Zuul</code>? I think I would need to override the instance of <code>LoadBalancer</code> for each of the routes. Any ideas how to do that?</p>

<p>That was actually quite easy. You only need to specify the <code>NIWSServerListClassName</code>, the <code>k8s</code> namespace and the k8s port name in the <code>Ribbon</code> configuration:</p>

<pre><code>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)
</code></pre>

<p>Then the <code>Zuul</code> route can refer to the service:</p>

<pre><code>zuul:
    routes:
        rm-data-store:
            path: /foo/**
            retryable: true
            service-id: service-name
</code></pre>
