My first question on stackoverflow, hope to get some help 🙂
I have a spring cloud gateway (using webflux) on kubernetes. My all other microservices is also sit on kubernetes on same cluster with ingress allowed only from api gateway so that all request can only go through gateway.
Problem I am facing is when I give any other service kubernetes path e.g http://myappservice.namespace.svc.clustor.local as route uri in gateway property and try to hit it gives upstream timeout, but if with in gateway I write a rest controller and call the same service with same kubernetes uri path through a simple rest template it works fine. So for sure it had access and there is no ingress and egress issue but why it could not call other services as proxy is mystery
Anyone have any clue?
Thanks
Ravi
Related
Here we use Spring Cloud Gateway , Eureka Server and some microservices.
When the user (frontend) call a rest service he needs to call the gateway then the gateway do the loadbalance and returns the result for the user. (OK)
Our problem is when this rest service call other rest service after pass by the gateway.
When this fact occur we call the gateway again to do this call, is it ok to do? Or the best practice would be use a client loadbalance to do this request direct on the service dont using the gateway again.
Anyone could help me about this doubt?
Thanks a lot!
I am trying to deploy a simple microservice application (Spring boot) in GAE. The application has 3 services -
1. Discovery Service
2. Spring Cloud Gateway
3. Customer service
I am trying to call an API through API gateway. This works fine in local machine but getting 404 in GAE hosted application.
The URL I am using is - https://Gateway-url/customer-service/version
And corresponding YAML config is :
spring:
cloud:
gateway:
routes:
-id: customer-service
uri: https://XXXXXX.customer-service.appspot.com/
predicates:
- Path=/customer-service/**
filters:
- StripPrefix=1
The URI configured in above code snippet is - target URL of GAE service.
So When I hit the https://Gateway-url/customer-service/version url in browser, I am getting 404 error but it works if I hit the direct url https://customer-service-url/version
When I changed the API Gateway configuration in the local environment, (change uri to cloud based service uri), the issue is reproducible. So I am thinking that Gateway is not able to route the requests to App Engine Service target URL.
How can I fix this problem?
I think the problem is the url that you are using in the configuration file to route your requests.
According to google cloud documentation, to call from one service to another you should use a endpoint like this
https://VERSION_ID-dot-SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com
As yo can see here
https://cloud.google.com/appengine/docs/standard/java/communicating-between-services
And it seems that the url that you are using doesn't fit int this.
Anyway I think that in a serverless environment such as app engine the best option to perform service discovery and to route requests via gateway is using the services provided by google. In case of service discovery it is done automatically and if you want a gateway you can use google cloud endpoints that have a greate integration with app engine. Because this is the gateway intended to use with these applications
I had enable SSL on Spring Cloud Gateway service, and after that routing such as
.route("instruments-ui", r -> r.path("/instruments/**")
.filters(f -> f.filter(addCredentials.apply()).preserveHostHeader())
.uri("lb://instruments-ui"))
ceased normally working. If I change uri to real address such as http://localhost:8001 routing working right. I use Gateway version 2.0.0.RC1. Can anybody explain how to setup Spring Cloud Gateway + routing with Eureka data + SSL?
If your Gateway works with SSL and downstream services works without it, then you need to specify uri as for example .uri("lb:http://instruments-ui"). I found it after viewing LoadBalancerClientFilter class.
I am writing microservices with Spring Cloud.
I'm also using Zuul as the API Gateway which routes some URLs to destination services which are not registered into Eureka.
When a new route needed to be added to Zuul, we often edit the application.yml file and then restart the Zuul server.
I was wondering is there a way to add new route into Zuul without restarting the Zuul server?
I found this link useful but it only works for services registed in Erueka.
I am not experienced in spring micro services and zuul configuration so I will need some help.
I have a microservice running on jhipster-registry and I am trying to access the microservice from my application through the gateway.
In my application I have this service in the current routes:
If I am accessing the service when my application is started as a spring boot app everything works fine; but when I deploy my application on tomcat the same request returns 404.
Here is the zuul config :
zuul:
routes:
assessmentapi:
path: /assessmentapi/**
serviceId: assessmentapi
url: http://192.168.80.44:8081/assessment-api
and http get request
$http.get('/assessmentapi/main/....)
You should not write the URL part in your configuration. As we can see on your gateway screenshot, the gateway already knows the service's IP thanks to Eureka and the Registry. IP addresses should never go into the config as those are determined dynamically.