Gateway API with Traefik

Hello,

we’ve changed the Ingress implementation on our Rancher Kubernetes cluster from “Ingress-NGINX” to “Traefik” through the cluster config ui.

All our ingresses do work after recreating them.

However, one application used `ImplementationSpecific` matching within their Ingress for matching on RegEx patterns.

To make it work with patterns I’m trying to migrate that specific Ingress to the new Gateway API.

My goals are:

  • keep all `Ingress`es as `Ingress`
  • migrate that one specific `Ingress` to `Gateway` + `HTTPRoute`

To enable the Gateway API, I’ve found that I have to enable it:

apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
  name: rke2-traefik
  namespace: kube-system
spec:
  valuesContent: |-
    providers:
      kubernetesGateway:
        enabled: true

To test the Gateway API, I’ve created an example without patterns first:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: markus-whoami
  namespace: markus
  labels:
    app: markus-whoami
spec:
  selector:
    matchLabels:
      app: markus-whoami
  replicas: 1
  template:
    metadata:
      labels:
        app: markus-whoami
    spec:
      containers:
      - image: traefik/whoami
        name: markus-whoami
        ports:
          - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: markus-whoami-service
  labels:
    app: markus-whoami
spec:
  selector:
    app: markus-whoami
  ports:
    - port: 80
      targetPort: 80
      name: service-port
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: markus-gateway
  namespace: markus
  annotations:
    cert-manager.io/cluster-issuer: rancher-ca-issuer
spec:
  gatewayClassName: traefik
  listeners:
    - name: https
      protocol: HTTPS
      port: 443
      hostname: "whoami.markus.our-cluster"
      tls:
        mode: Terminate
        certificateRefs:
          - name: markus-whoami-zertifikat
    - name: http
      protocol: HTTP
      port: 80
      hostname: "whoami.markus.our-cluster"
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: markus-whoami-route
  namespace: markus
spec:
  parentRefs:
    - name: markus-gateway
      namespace: markus
      sectionName: https
  hostnames:
    - "whoami.markus.our-cluster"
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: markus-whoami-service
          port: 80

However, this “simple” routing is not working, neither for HTTP nor HTTPS.

The Traefik containers contain the following error:

Gateway Not Accepted error=“Cannot find entryPoint for Gateway: no matching entryPoint for port 443 and protocol “HTTPS”\nCannot find entryPoint for Gateway: no matching entryPoint for port 80 and protocol “HTTP”” gateway=markus-gateway namespace=markus providerName=kubernetesgateway

Since normal `Ingress` definitions to work with Traefik, 443 and 80 should be open and working.

Is there any step I have missed?

Just an observation, isn’t a Gateway Class required? https://traefik.io/glossary/kubernetes-gateway-api?

Yes, using the above `rke2-traefik` HelmChartConfig creates one:

❯ kubectl get gatewayclass
NAME      CONTROLLER                      ACCEPTED   AGE
traefik   traefik.io/gateway-controller   True       3h3m
1 Like