spring-cloud-kubernetes
spring-cloud-kubernetes copied to clipboard
The spring cloud gateway app can not start up after upgrade form 1.1.10-RELEASE to 2.1.3
env: spring-cloud-starter-gateway 3.1.3 spring-cloud-kubernetes-discovery 2.1.3
When the app starts, gets below error.
" Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'reactiveCompositeDiscoveryClient' defined in class path resource [org/springframework/cloud/client/discovery/composite/reactive/ReactiveCompositeDiscoveryClientAutoConfiguration.class]: Unsatisfied dependency expressed through method 'reactiveCompositeDiscoveryClient' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kubernetesReactiveDiscoveryClient' defined in class path resource [org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientAutoConfiguration$Reactive.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.client.discovery.ReactiveDiscoveryClient]: Factory method 'kubernetesReactiveDiscoveryClient' threw exception; nested exception is org.springframework.cloud.kubernetes.discovery.DiscoveryServerUrlInvalidException: spring.cloud.kubernetes.discovery-server-url must be specified and a valid URL. "
I want to confirm that, in my spring cloud gateway app, I use spring cloud Kubernetes discovery to get services from K8s API server, it works well with 1.1.x-RELEASE. And for upgrading to 2.0.0+ version, if it means I need to deploy a discovery server and config the discovery server URL in my spring cloud gateway app yaml? Thanks.
Sounds like you want to use spring-cloud-starter-kubernetes-client
or spring-cloud-starter-kubernetes-fabric8
.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Sounds like you want to use
spring-cloud-starter-kubernetes-client
orspring-cloud-starter-kubernetes-fabric8
.
Hi, I just want the spring cloud gateway discovering the service deployed in the K8s cluster by adding some configuration in spring-boot properties, so when the HTTP request comes, the gateway can route the request to the correct service for processing.
Configuration as below.
spring.cloud.discovery.client.health-indicator.enabled=false spring.cloud.kubernetes.discovery.enabled=true spring.cloud.gateway.discovery.locator.enabled=false spring.cloud.gateway.discovery.locator.lower-case-service-id=true spring.cloud.kubernetes.reload.enable=true spring.cloud.kubernetes.reload.mode=polling spring.cloud.kubernetes.reload.period=5000 spring.cloud.kubernetes.client.namespace=dev
spring.cloud.gateway.routes[0].id=my-service1-route spring.cloud.gateway.routes[0].uri=lb://my-service1:5010 spring.cloud.gateway.routes[0].predicates[0]=Path=/my-service1/**
spring.cloud.gateway.routes[1].id=my-service2-route spring.cloud.gateway.routes[1].uri=lb://my-service2:5020 spring.cloud.gateway.routes[1].predicates[0]=Path=/my-service2/****
Right you have the wrong dependency on your classpath, you need to choose one of the two I listed above.
I will hava a try
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
@ryanjbaxter @yumingtao I'm facing the same issue. I created this test project: https://github.com/rcbandit111/mockup/blob/master/src/main/resources/application.yml
More description: https://stackoverflow.com/questions/78249919/discoveryserverurlinvalidexception-spring-cloud-kubernetes-discovery-server-url
Can you advice any possible solution, please?
Ah, I commented on the stackoverflow, but you miss at least this simple thing :) You have it as :
spring:
cloud:
kubernetes:
discovery-server-url: "spring-cloud-kubernetes-discoveryserver.default.svc:8761"
and it should be:
spring:
cloud:
kubernetes:
discovery:
discovery-server-url: "spring-cloud-kubernetes-discoveryserver.default.svc:8761"
Also please upgrade and let's see from there...
It solved the issue. Thanks