GraphQL server to server connection timeout on Kubernetes

11/20/2019

I have 3 services currently running on the gcloud kubernetes platform.

The frontend connects to the backend via a graphql query and asks for some data. This query is forwarded to another service which is responsible for the specific type of data i.e "bread".

So you have frontend (react/next.js) -> backend #1 (graphql) -> backend #2 (graphql)

All of these can communicate within the cluster, I can check the logs via "kubectl logs podname".

The logs basically say:

  1. Backend #1: Received query
  2. Backend #2: Received query (this is where it queries the database).
  3. Backend #1:

    ,"level":50,"msg":"Failed to fetch bread from breadservice. FetchError: request to http://bread-service/graphql failed, reason: connect ETIMEDOUT some.ip.address:15\n

I am not sure why this timeout error occurs. All the services can communicate successfully.

-- BURGERFLIPPER101
gcloud
graphql-js
kubernetes

1 Answer

11/20/2019

I suggest to use apollo-gateway for the same, you can find details here, this will add a gateway layer in between where you can define all the URLs of the services those are supposed to communicate with each other.

And just expose the gateway via ingress.

And in the above case, I guess you are missing the port number of the service

http://bread-service:port/graphql 

Try this, I guess this should be working.

But do have a look at that link, for microservices that looks good for implementation, I am also exploring the same

-- Tushar Mahajan
Source: StackOverflow