aws / aws-app-mesh-controller-for-k8s

A controller to help manage App Mesh resources for a Kubernetes cluster.
Apache License 2.0
187 stars 109 forks source link

Nginx doesn't respect app mesh routing #474

Open himanshurajput32 opened 3 years ago

himanshurajput32 commented 3 years ago

Hi

We are using Nginx with App mesh on EKS. Nginx has 2 upstreams that are running on the same EKS cluster/namespace and namespace. Each upstream has two versions running of itself. We are trying to achieve header-based routing for accessing both versions on an upstream. We are setting the Header while proxying to an upstream from Nginx. The upstreams have their own virtual service, virtual routes, and 2 virtual nodes for each version of upstream.

It seems that Nginx is not respecting the virtual router rule set for each upstream and It's using default K8s service discovery, sending traffic to each version of each upstream.

Here is Nginx config -

location / {
  proxy_pass http://SERVICE-A:PORT/;
  proxy_set_header Host "SERVICE-B";
  proxy_set_header release-version "release-1";
}

location /api {
  proxy_pass http://SERVICE-B:PORT/;
  proxy_set_header Host "SERVICE-B";
  proxy_set_header release-version "release-1";
}

The header name is release-version with value release-1. All the components are running in the same namespace on EKS.

achevuru commented 3 years ago

@himanshurajput32 Is Nginx part of a mesh? or is it outside of the mesh? You can use VirtualGateway here and set your config in VG instead.

himanshurajput32 commented 3 years ago

@achevuru Yes Nginx is part of mesh and created a Virtual Node for this. Nginx should be exposed on a public URl so We have used ALB ingress controller to expose it as mentioned on

https://github.com/aws/aws-app-mesh-examples/blob/master/walkthroughs/howto-k8s-alb/v1beta2/manifest.yaml.template