title: What is the correct way to use feign with spring cloud kubernetes?
body: <p>I am using Spring Cloud Kubernetes and I am trying to make feign able to send requests based on the name of the services present in kubernetes, but I can't, when I try to make a request the following error occurs:</p>
  
  <pre><code>  "timestamp": "2019-12-06T15:37:50.285+0000",
      "status": 500,
      "error": "Internal Server Error",
      "message": "com.netflix.client.ClientException: Load balancer does not have available server for client: poc-saldo",
      "trace": "java.lang.RuntimeException: com.netflix.client.ClientException: Load balancer does not have available server for client: poc-saldo\n\tat org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient.execute....
  </code></pre>
  
  <p>I tried to call other services within the cluster and the problem is the same for all of them, I did a test by going into the poc-deposit pod and doing a poc-balance curl and it works normally, so the problem is not with the poc-deposit service. balance or with kubernetes's service discovery apparently.</p>
  
  <p>The project has a public profile at:</p>
  
  <pre><code>https://gitlab.com/viniciusxyz/spring-kubernetes-feign
  </code></pre>
  
  <p>For those who want more direct information:</p>
  
  <p>My main class is as follows:</p>
  
  <pre><code>@SpringBootApplication
  @EnableDiscoveryClient
  @EnableFeignClients
  public class ServiceDiscoveryApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(ServiceDiscoveryApplication.class, args);
      }
  
  }
  </code></pre>
  
  <p>My interface with feign is as follows:</p>
  
  <pre><code>@FeignClient("poc-saldo")
  public interface ProxyGenerico {
  
      @RequestMapping(method = RequestMethod.GET)
      String getHttpResponse();
  
  }
  </code></pre>
  
  <p>I can list the services available in kubernetes within the application as follows:</p>
  
  <pre><code>@RestController
  public class RestTest {
  
      @Autowired
      private DiscoveryClient discoveryClient;
  
      @Autowired
      private ProxyGenerico proxyGenerico;
  
      @GetMapping("/services")
      public ResponseEntity&lt;?&gt; services()  {
          return new ResponseEntity&lt;Object&gt;(discoveryClient.getServices(), HttpStatus.OK);
      }
  
      @GetMapping("/pocsaldo")
      public ResponseEntity&lt;?&gt; gitlab()  {
  
          return new ResponseEntity&lt;Object&gt;(proxyGenerico.getHttpResponse(), HttpStatus.OK);
      }
  
  }
  </code></pre>
  
  <p>And in this list I have several services among them the service I want to access called poc-balance, the return json looks like the following:</p>
  
  <pre><code>[
  
      "poc-deposito",
      "poc-saldo",
      "sonarqube",
      "sql-server-sonar",
      "zookeeper",
      "gitlab"
  
  ]
  </code></pre>
  
  <p>To complement the list follow my dependencies:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
      &lt;artifactId&gt;spring-cloud-starter-openfeign&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
      &lt;artifactId&gt;spring-cloud-starter-kubernetes&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
      &lt;artifactId&gt;spring-cloud-starter-kubernetes-ribbon&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>The discoveryClient.getInstances ("poc-saldo") command returns:</p>
  
  <pre><code>[
      {
          "instanceId": "32a4db0d-0549-11ea-8850-e0d55ef66cf8",
          "serviceId": "poc-saldo",
          "secure": false,
          "metadata": {
              "helm.sh/chart": "spring-boot-app-0.1.23",
              "port.http": "8080",
              "app.kubernetes.io/managed-by": "Tiller",
              "app.kubernetes.io/name": "poc-saldo",
              "app.kubernetes.io/instance": "banco-digital-poc-saldo",
              "app.kubernetes.io/version": "1.0"
          },
          "port": 8080,
          "host": "10.42.0.60",
          "scheme": "http://",
          "uri": "http://10.42.0.60:8080"
      }
  ]
  </code></pre>
  
  <p>Can you think of where the problem might be?</p>