Search code examples
javaspring-bootkubernetesspring-cloudspring-cloud-kubernetes

spring.cloud.kubernetes.discovery.discovery-server-url - what is the correct url?


I am just setting two simple services on Mac using minikube

I have the service set up and I can access it via ingress / minikube tunnel . So i know the service works

I am using Spring Boot 3, with the so i need to specify the spring-cloud-starter-kubernetes-all package. This means I need to specify a url for spring.cloud.kubernetes.discovery.discovery-server-url

When i try to do the simple call to

discoveryClient.getServices()

I get the error "Connection refused https://kubernetes.docker.internal:6443/apps"

"apps" is my second service

It is refusing connection to the value of spring.cloud.kubernetes.discovery.discovery-server-url

At the moment i have this set to spring.cloud.kubernetes.discovery.discovery-server-url=https://kubernetes.docker.internal:6443

I am assuming this is incorrect and I need some help as to what is the correct url to set this to / or the correct place to find this. I thought this would be the internal url.


Solution

  • You are trying to configure your discovery client with the Kubernetes API server URL, which is incorrect. Your client application needs to be connected to Spring Cloud Kubernetes Discovery Server. It's an independent application that will work like a proxy between your client SpringBoot apps and Kubernetes. You can find its images here: https://hub.docker.com/r/springcloud/spring-cloud-kubernetes-discoveryserver/tags And it should be deployed to Kubernetes via yaml file.

    Then you can configure spring.cloud.kubernetes.discovery.discovery-server-url with this discovery server URL. That URL will most likely come from a Kubernetes service that you will create for the discovery server application.

    Please, find the full deployment YAML and the related documentation here: https://spring.io/blog/2021/10/26/new-features-for-spring-cloud-kubernetes-in-spring-cloud-2021-0-0-m3

    Please, let us know how that goes