Can't use Kubernetes Gateway with Traefik

I installed Traefik via helm:

helm install traefik traefik/traefik

Then I created a GatewayClass as shown here

apiVersion: gateway.networking.k8s.io/v1alpha2
kind: GatewayClass
metadata:
  name: my-gateway-class
spec:
  # Controller is a domain/path string that indicates
  # the controller that is managing Gateways of this class.
  controllerName: traefik.io/gateway-controller

But this doesn't seem to work as expected:

❯ k describe gatewayclass
Name:         my-gateway-class
Namespace:
Labels:       <none>
Annotations:  <none>
API Version:  gateway.networking.k8s.io/v1alpha2
Kind:         GatewayClass
Metadata:
  Creation Timestamp:  2022-01-25T18:57:59Z
  Generation:          1
  Managed Fields:
    API Version:  gateway.networking.k8s.io/v1alpha2
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .:
          f:kubectl.kubernetes.io/last-applied-configuration:
      f:spec:
        .:
        f:controllerName:
    Manager:         kubectl-client-side-apply
    Operation:       Update
    Time:            2022-01-25T18:57:59Z
  Resource Version:  1013
  UID:               44815eea-869b-4d11-bc8e-e6e4f80544b6
Spec:
  Controller Name:  traefik.io/gateway-controller
Status:
  Conditions:
    Last Transition Time:  1970-01-01T00:00:00Z
    Message:               Waiting for controller
    Reason:                Waiting
    Status:                Unknown
    Type:                  Accepted
Events:                    <none>

Am I doing something wrong here?

2 Likes

Having the exact same problem.

I'm using k3s. This version of kubernetes already includes Traefik 2.6, but when looking at kubectl describe deploy traefik, neither --experimental.kubernetesgateway=true, --providers.kubernetesgateway=true nor --experimental.kubernetesGateway.enabled=true is set. I got the first two keys from traefik gateway api documentation for version 2.6, and the last key from traefik's getting started blog post. I tried to do kubectl patch deploy traefik --patch-file=... with this file

spec:
  template:
    spec:
      containers:
        - args:
          - --experimental.kubernetesGateway.enabled=true
          - --experimental.kubernetesgateway=true
          - --providers.kubernetesgateway

However, I got an error saying Error from server: map: map[args:[--experimental.kubernetesGateway.enabled=true]] does not contain declared merge key: name. I don't know enough about patching that I'm able to solve this on my own.

I came across this post, and then further navigated to the documentation page explaining static and dynamic configuration

In the output of docker run traefik:v2.6 --help I see this commandline argument

--experimental.kubernetesgateway  (Default: "false")
    Allow the Kubernetes gateway api provider usage.
...
--providers.kubernetesgateway  (Default: "false")
    Enable Kubernetes gateway api provider with default settings.

So it seems like that's the only command line arguments you need to pass to enable the gateway api. The way I updated the configuration is by kubectl describe deploy traefik (reminding the reader that I'm using k3s) and I pasted the output to a new yaml file and deleted the status key entirely. Then I added the two keys above to the args section, and ran kubectl delete deploy traefik then kubectl apply -f <yamlfile>. Now the new traefik deployment runs with the two arguments.

However, this didn't solve the problem. 16 minutes after applying but still Message: Waiting for controller.