Call other rest service after pass by the gateway - Implementation - microservices

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!

Related

How to take response from one service and send it to another service using Spring cloud gateway

TLDR : Is it okay to use controller class in spring gateway instead of routing in config class? I want to take data from one service and then pass it the response from that service to another.
I used spring cloud gateway to create an api gateway. I have several services that need to communicate. I currently only use the gateway for routing to the first service and then the first service is going to talk to other service by itself. But this is becoming troublesome now that I have a lot of services.

Spring Cloud gateway on kubernetes timeout

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

How to configure Feign Client to work with API Gateway?

I have the following services
Service A - Sends request to service B using RestTemplate.
Service B - Has an end point that returns "Hello Universe".
Service G - "Spring Cloud Gateway".
Service A sends request to Service B using API Gateway URL using REST Template.
But, how does it work with Feign Client? For example below is the FeignClient of Service B in Service A
#FeignClient(name = "serviceb")
public interface ServiceBClient {
#GetMapping("/getmessage/")
public Inventory getInventoryDetails();
}
I believe one of the primary reasons we use a gateway is to allow the service A to send request to Gateway instead of directly using the service name.
But it seems with feign client the purpose is destroyed.
How to send request to Gateway using feign client?
if you want to give the URL of API-gateway, you can provide it instead of the service name. then the request doesn't go to the related service and, the request goes to the API gateway and, the API gateway will route the request to the relevant service. then the API gateway will be busy for nothing. because, if you gave the service name, the request directly goes to the request by using the cached services IP address data. due to the internal request, the request doesn't want to go through the security filters as well.
#FeignClient(url = "http://localhost:8081/order-service")

Integrate cognito with spring-boot microservice

This could sound like a very noob question, so let me apologies first.
We have multiple lambda services (JavaScript) added that uses AWS cognito. I know that AWS cognito is majorly designed for authentication and authorisation in serverless architecture.
But now I have a microservice written in Java using spring boot which is deployed behind the AWS api gateway. The gateway is running as a proxy to the service's resources. So our client app authenticates users using cognito and used Authorization and api key to access our services which have AWS_IAM and api key authenticating every request to the service on the gateway.
To perform some tasks in the service cognitoIdentityId is required. In case of JS lambda services we receive it in the event json in its context field. But I could not find any way for the spring-boot service to receive it. Neither HttpSession nor HttpServletRequest have that info. Requests are not directly authenticated with the service so spring SecurityContext's principal is also empty/anonymous. The documentation on cognito with http services is very bleak and most of the discussions starts and ends with Lambda.
Can anyone point me to the right direction as how to get the id?
Thanks in advance.

how to use spring gateway in a cloudfoundry routing service

We would like to use Spring Cloud Gateway to implement a CloudFoundry Route Service.
In short: every request coming in to the 'Route Service' needs to be forwarded to a url defined as a Request Header (X-CF-Forwarded-Url). The request can be modified/blocked by the 'Route Service' id required.
From what I see (and as the name implies) Spring Cloud gateway is only able to proxy a request. Is it possible to do something like that?
Why 'Spring Cloud Gateway'? I think it provides a very nice API and lots of thoughts have gone into it. It also just feels as a very related usecase/extension to the whole API.

Resources