emissary-ingress / emissary

open source Kubernetes-native API gateway for microservices built on the Envoy Proxy
https://www.getambassador.io
Apache License 2.0
4.32k stars 684 forks source link

Emissary sending requests to 2 separate services as a round-robin despite hostname #5618

Closed yalattas closed 2 months ago

yalattas commented 2 months ago

Describe the bug I am trying to have multiple mappings for the same host. And I'm progressing to add another host my hosts as follows:

I have a single listener, not sure if I should add multiple listeners or not. Currently I am trying the setup locally with kind cluster and Ambassador is doing round-robin which fails to render many resources as 404

My desired architecture would be having Ingress for external traffic + TLS -> Ingress forward to traffic as http to Ambassador -> Ambassador send the traffic to respective service based on the hostname See below Screenshot from 2024-04-08 06-09-10

Next refresh image This is a correct response from the service as I didn't authenticate, once I authenticate. I shouldn't be seeing not found error

To Reproduce

apiVersion: getambassador.io/v3alpha1
kind: Listener
metadata:
  name: app-listener
  namespace: ambassador
spec:
  port: 8080
  protocol: HTTP
  securityModel: INSECURE # insecure only
  hostBinding:
    namespace:
      from: ALL
---
apiVersion: getambassador.io/v2
kind: Host
metadata:
  name: cluster-host
  namespace: ambassador
spec:
  hostname: "*.cluster.local:8081" # port exists for local development, once deployed over the cloud will be removed and replaced with *.company.com
  requestPolicy:
    insecure:
      action: Route
---
apiVersion: getambassador.io/v2
kind: Mapping
metadata:
  name: argocd-mapping
  namespace: argocd
spec:
  hostname: argocd.cluster.local:8081 # port exists for local development, once deployed will be argocd.company.com
  prefix: /
  service: http://argocd-server:80 # service name and port
---
apiVersion: getambassador.io/v2
kind: Mapping
metadata:
  name: chartmuseum-mapping
  namespace: chartmuseum
spec:
  hostname: charts.cluster.local:8081 # port exists for local development, once deployed will be charts.company.com
  prefix: /
  service: http://chartmuseum:8080

Expected behavior visit charts.cluster.local:8081 > you should see response from charts.cluster.local and not service2.cluster.local visit argocd.cluster.local:8081 -> I should see only argoCD, sometimes I see argoCD and next refresh I see ChartMuseum page

Versions (please complete the following information):

yalattas commented 2 months ago

nevermind, i discovered the issue which was wrong argument name in mapping

apiVersion: getambassador.io/v2
kind: Mapping
spec:
  hostname:

should be

apiVersion: getambassador.io/v2
kind: Mapping
spec:
  host: