Kubernetes Services on Google Cloud, cookies are not passed

7/10/2020

I have created a cluster with 2 nodes and 3 pods in each node as shown in the attached image.

Each node is exposed via Service.

One node having the pods running the front end based on react and another node running the pods with backend service based on nodeJS

Frontend and Backend are accessible via the external IP address individually.

When the frontend application makes calls to the back end via REST APIs, cookies are not passed to the backend.

The Service is configured of type LoadBalancer

Question: anything to be configured at the Service definition or somewhere so that cookies are passed to the node running the backend pods?

Note: includecredentials flag is enabled when I make REST API calls to backend from the frontend when I fetch requests made and the same is working fine when we run in a local docker image via nginx reverse proxy

enter image description here

Below is the code snippet used on the frontend side to make REST API calls to nodeJS backend, after the authentication in the login page in the frontend access_token and id_token are stored in the cookie and they are expected to flow as part of the REST API call as the credentials field is enabled.

export function getFileMetadata(documentId: string, attributes: string) {
  return fetch(`${baseUrl}api/documents/${documentId}`, {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    credentials: 'include',
    body: JSON.stringify({
      attributes,
    }),
  })
    .then(async (response) => {
      const result = await handleResponse(response);
      return result;
    })
    .catch(handleError);
}
-- Santhosha
google-cloud-platform
kubernetes
load-balancing

0 Answers