Reputation: 407
I have 2 kubernetes cluster
cluster 2 - exposed loadblancer nginx with regional IP IP_PRIVATE
service 1 - website `/website`
service 2 - blog `blog`
service 3 - api `api`
cluster 1 - exposed loadblancer gce with global IP IP_PUBLIC
I want to implement this behaviour
IP_PUBLIC/api -> service 2 response
IP_PUBLIC/* -> cdn -> service 1 response
To implement this I have created cdn service layer in cluster 1 as defined here https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-features#expandable-1
Now my domain will be mapped to IP_PUBLIC hence any request will hit cluster 1 first then it should pass the request to cluster 2 and get the response.
Note: I have to create 2 clusters because
I want to pass the exact request (domain, headers etc) from cluster 1 to cluster 2 as if the request is directly hiting the cluster 2.
What is the correct way to do this? In case there is any alternate solution to achieve the above with minimum changes then please suggest.
Upvotes: 1
Views: 790
Reputation: 30113
i am not sure which ingress you are running in the background however you can change the config using the annotation.
You can enable passing the headers on Nginx using this annotation so it will forward all the custom headers and domain details.
enable-underscores-in-headers: true
with
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header My-Custom-Header $http_my_custom_header;
But I am not sure one part when you say :
Now my domain will be mapped to IP_PUBLIC hence any request will hit cluster 1 first then it should pass the request to cluster 2 and get the response.
One your request hit to domain traffic will maybe flows like
Request > domain > cluster 1 > cluster 1's service > IP or Domain of cluster 2 > cluster 2's ingress controller > cluster 2's service
in this case you need to pass the headers to request and enable ingress config on cluster2's controller so it will forward to details to backend service running on cluster2.
Also not sure how your egress traffic moving out of the cluster using NAT gateway or directly from node, considering you have a public cluster your service will be directly calling cluster2's domain in that case you have to add the headers with request.
Just set the proper annotation to ingress and your backend services will get the headers with domain details.
Upvotes: 1