Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirects don't work with hosts that use mappingSelector. #5464

Open
leandrorosa opened this issue Dec 5, 2023 · 2 comments
Open

Redirects don't work with hosts that use mappingSelector. #5464

leandrorosa opened this issue Dec 5, 2023 · 2 comments

Comments

@leandrorosa
Copy link

leandrorosa commented Dec 5, 2023

Describe the bug
Redirects are not being picked by emissary when it is associated with a Host by mappingSelector.
If the mappingSelector is removed from the Host it works.

To Reproduce
Create two hosts like this:

apiVersion: getambassador.io/v3alpha1
kind: Host
metadata:
  name: emissary-api-host
  namespace: emissary-ingress
spec:
  mappingSelector:
    matchLabels:
      type: api
  hostname: api.emissary.com
---
apiVersion: getambassador.io/v3alpha1
kind: Host
metadata:
  name: emissary-frontend-host
  namespace: emissary-ingress
spec:
  mappingSelector:
    matchLabels:
      type: frontend
  hostname: frontend.emissary.com

And then create a redirect like this:

apiVersion: getambassador.io/v3alpha1
kind:  Mapping
metadata:
  name: testing-redirect
  namespace: emissary-ingress
  labels:
    type: frontend
spec:
  hostname: '*'
  prefix: /redirect/test
  service: www.getambassador.io
  host_redirect: true
  prefix_redirect: /company/about-us

The redirect will not work.
If the mappingSelector is removed from the hosts it works.

Expected behavior
Redirects being applied with the mappingSelector.

Versions (please complete the following information):

  • Emissary-ingress: 3.9.1
  • Kubernetes environment: AKS
  • Version 1.25.6
@cindymullins-dw
Copy link
Contributor

Hi @leandrorosa, I think this is because of the wildcard hostname in the Mapping. "If the Host defines a mappingSelector and the Mapping also defines a hostname, both must match. Mapping with a hostname of "*" will associate with any Host that has no mappingSelector." A wildcard is probably not considered a match.

@ronipardo
Copy link

HI @cindymullins-dw,
We started to have a similar issue after upgrading from 3.1.0 to 3.7.2

We have one host:

apiVersion: getambassador.io/v3alpha1
kind: Host
metadata:
  name: wildcard
spec:
  ambassador_id: ["ambassador"]
  hostname: '*'
  acmeProvider:
    authority: none         
  requestPolicy:
    insecure:
      action: Route
  mappingSelector:
    matchLabels:
      foo: bar

Adding here 2 example of mappings, 1 of them with host_redirect: true

apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
  name: jobs-redirect
  labels:
    foo: bar
spec:
  ambassador_id: ["ambassador"]
  host_redirect: true
  precedence: 200
  prefix: /jobs
  prefix_redirect: /careers
  service: XYZ.com
  timeout_ms: 60000

and

apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
  name: no-host-redirect
  labels:
    foo: bar
spec:
  ambassador_id: ["ambassador"]
  precedence: 200
  prefix: /test
  prefix_redirect: /testing
  service: XYZ.com
  timeout_ms: 60000

Only the one with the host_redirect isn't working ( we don't see it in the envoy/envoy.json)

After we removed the mappingSelector from the host resource and added hostname: * in the mapping it started to work.
Another solution was to add DISABLE_STRICT_LABEL_SELECTORS: "true" environment variable.

Is there any issue with host_redirect mapping?

Versions:

  • ambassador edge stack 3.7.2 (emissary ingress 3.7.2)
  • Kubernetes environment: EKS, 1.27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants