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.37k stars 685 forks source link

Mapping using hostname does not work #4714

Open ericfuxealth opened 1 year ago

ericfuxealth commented 1 year ago

Describe the bug Using "hostname" in mapping does not work, but "host" works.

To Reproduce Steps to reproduce the behavior:

  1. Install emissary-ingress using helm chart:
    
    helm repo add datawire https://app.getambassador.io
    helm repo update
    kubectl apply -f https://app.getambassador.io/yaml/emissary/3.3.0/emissary-crds.yaml
    kubectl wait --timeout=90s --for=condition=available deployment emissary-apiext -n emissary-system

helm install -n emissary --create-namespace \ emissary-ingress datawire/emissary-ingress && \ kubectl rollout status -n emissary deployment/emissary-ingress -w


2. Notice deployment " emissary-ingress-agent" and "emissary-ingress" are using different version of the image: 

apiVersion: apps/v1 kind: Deployment metadata: name: emissary-ingress-agent namespace: default labels: app.kubernetes.io/name: emissary-ingress-agent helm.sh/chart: emissary-ingress-8.3.0 app.kubernetes.io/instance: emissary-ingress app.kubernetes.io/part-of: emissary-ingress app.kubernetes.io/managed-by: Helm product: aes spec: ... spec: serviceAccountName: emissary-ingress-agent containers:

  1. Change the mapping to use "host" Observe the mapping now works.

Expected behavior Routing using the mapping should work.

Versions (please complete the following information):

Additional context Add any other context about the problem here.

ericfuxealth commented 1 year ago

Additionally, "hostname" in Host doesn't work.

The following configuration fails to work:

apiVersion: getambassador.io/v3alpha1
kind: Listener
metadata:
  name: emissary-ingress-listener-8443
  namespace: emissary
spec:
  port: 8443
  protocol: HTTPS
  securityModel: SECURE
  hostBinding:
    namespace:
      from: ALL
    selector:
      matchLabels:
        external-hosts: "true"
---
apiVersion: getambassador.io/v3alpha1
kind: Host
metadata:
  name: host-external
  namespace: emissary
  labels:
    external-hosts: "true"
spec:
  hostname: "server.example.com"  <<<<<<<<< Removing this line it will work.
  acmeProvider:
    authority: none
  tlsSecret:
    name: emissary-selfsigned-cert
    namespace: emissary
  selector:
    matchLabels:
      external-mapping: "true"
---
apiVersion: getambassador.io/v2
kind: Mapping
metadata:
  name: server
  namespace: emissary
  labels:
    external-mapping: "true"
spec:
  # host: "server.example.com"
  prefix: /
  service: server:3002

When "hostname" is removed from Host and "host" is enabled in Mapping it will start working.

ericfuxealth commented 1 year ago

Update: once I started using "apiVersion: getambassador.io/v3alpha1" for Mapping, the "hostname" field does work.

However, "hostname" field in Host still does not work.

This is the updated code:

apiVersion: getambassador.io/v3alpha1
kind: Listener
metadata:
  name: emissary-ingress-listener-8443
  namespace: emissary
spec:
  port: 8443
  protocol: HTTPS
  securityModel: SECURE
  hostBinding:
    namespace:
      from: ALL
    selector:
      matchLabels:
        external-hosts: "true"
---
apiVersion: getambassador.io/v3alpha1
kind: Host
metadata:
  name: host-external
  namespace: emissary
  labels:
    external-hosts: "true"
spec:
  hostname: "server.example.com"  <<<<<<<<< Removing this line it will work.
  acmeProvider:
    authority: none
  tlsSecret:
    name: emissary-selfsigned-cert
    namespace: emissary
  selector:
    matchLabels:
      external-mapping: "true"
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
  name: server
  namespace: emissary
  labels:
    external-mapping: "true"
spec:
  hostname: "server.example.com"  <<<<<<<<< This works after removing hostname from Host
  prefix: /
  service: server:3002