Skip to content

Support zero hostnames in HTTPRoute #606

Closed
@pleshakov

Description

@pleshakov

Describe the bug
NGINX Kubernetes Gateway doesn't try to attach to a listener if an HTTPRoute has 0 hostnames.

To Reproduce
Steps to reproduce the behavior:

Gateway -- https://github.com/nginxinc/nginx-kubernetes-gateway/blob/f74c06ded5c3d647b0909fe542f3e70dbc96774c/examples/cafe-example/gateway.yaml

HTTPRoute:

apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
  name: coffee
spec:
  parentRefs:
  - name: gateway
    sectionName: http
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /coffee
    backendRefs:
    - name: coffee
      port: 80

In the status of the HTTPRoute, NKG reports:

Status:
  Parents:
    Conditions:
      Last Transition Time:  2023-05-03T15:55:08Z
      Message:               Listener hostname does not match the HTTPRoute hostnames
      Observed Generation:   1
      Reason:                NoMatchingListenerHostname
      Status:                False
      Type:                  Accepted
    Controller Name:         k8s-gateway.nginx.org/nginx-gateway-controller
    Parent Ref:
      Group:         gateway.networking.k8s.io
      Kind:          Gateway
      Name:          gateway
      Namespace:     default
      Section Name:  http

Expected behavior

  • HTTPRoute attaches to a listener
  • Traffic (in this example) - curl <any-host>/coffee routes to coffee service

Additional context

Conformance tests often don't include hostnames in HTTPRoutes. Example -- https://github.com/kubernetes-sigs/gateway-api/blob/v0.6.2/conformance/tests/httproute-matching.yaml

Metadata

Metadata

Assignees

Labels

area/httproute/coreRelates to all Core features of HTTPRoutebugSomething isn't workingconformanceRelates to passing Gateway API conformance testsrefinedRequirements are refined and the issue is ready to be implemented.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions