projectcontour / contour

Contour is a Kubernetes ingress controller using Envoy proxy.
https://projectcontour.io
Apache License 2.0
3.7k stars 671 forks source link

HTTPRoute conflicts when specifying a fallback https listener #6547

Open hatsuyuki15 opened 1 month ago

hatsuyuki15 commented 1 month ago

What steps did you take and what happened:

Given the following gateway:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: contour
  namespace: projectcontour
spec:
  gatewayClassName: contour
  listeners:
    - name: http
      protocol: HTTP
      port: 80
      allowedRoutes:
        namespaces:
          from: All

    - name: https-example.com
      protocol: HTTPS
      port: 443
      hostname: "*.example.com"
      allowedRoutes:
        namespaces:
          from: All
      tls:
        certificateRefs:
          - name: "wildcard-example.com-tls"
            kind: Secret

    - name: https
      protocol: HTTPS
      port: 443
      allowedRoutes:
        namespaces:
          from: All
      tls:
        certificateRefs:
          - name: "default-tls"
            kind: Secret

HTTPRoute:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: example.com
spec:
  hostnames:
    - "*.example.com"
  rules:
    - backendRefs:
        - name: example
          port: 8080
          kind: Service
  parentRefs:
    - name: contour
      group: gateway.networking.k8s.io
      namespace: projectcontour
      kind: Gateway

Applying the HTTPRoute above will always result in HTTPRoute's Match has conflict with other HTTPRoute's Match error. If I remove either https-example.com or https listener, it will work again. The above HTTPRoute is the only route in the system (there is no other route to cause conflict)

What did you expect to happen:

The HTTPRoute should be accepted.

Anything else you would like to add: It seems like the HTTPRoute is attached to both https-example.com and https listener. Each attachment is treated by contour as a separated HTTPRoute, which will lead to conflict.

Environment:

github-actions[bot] commented 1 month ago

Hey @hatsuyuki15! Thanks for opening your first issue. We appreciate your contribution and welcome you to our community! We are glad to have you here and to have your input on Contour. You can also join us on our mailing list and in our channel in the Kubernetes Slack Workspace