<p>I have spring boot app which I use <code>spring-cloud-kubernetes</code> dependencies. This is deployed in K8s. I have implemented service discovery and I have <code>@DiscoveryClient</code> which gives me service ids k8s namespace.My Problem is I want to do a rest call to one of this found services ( which have multiple pods running). How to do this ? Do I have to use Ribbon Client ?</p>

<p>My Code is</p>

<pre><code>@RestController
public class HelloController {

@Autowired
private DiscoveryClient discoveryClient;


@RequestMapping("/services")
public List&lt;String&gt; services() {
    log.info("/services - Request Received " + new Date());
    List&lt;String&gt; services = this.discoveryClient.getServices();
    log.info("Found services " + services.toString());
    for (String service : services) {
        // TODO call to this service
        List&lt;ServiceInstance&gt; instances = discoveryClient.getInstances(service);
        for (ServiceInstance instance : instances) {
            log.info("Service ID &gt;&gt; " + service + " : Instance &gt;&gt; " + getStringVal(instance));

        }
    }

    return services;
}
</code></pre>

<p>In service instances I can find host and port to call, but I want to call to service so that some load balancing mechanism calls to actual pod instance. </p>

Viraj
<p>You need to use Spring Cloud Kubernetes Ribbon to call the host and port which will go to the kubernetes service and you get the load balancing provided by Kubernetes service and Kube Proxy.</p>
