Getting started with Kubernetes Gateway API and Traefik

If you are still struggling to solve the issues in this blog, the following steps will solve the issue

1 Like

I was able to put together a series of steps to get up and going within my local development environment. Thus, it may assist you and it can be found here:

1 Like

Thanks for taking the time to write this up, it's a huge help for a beginner! Unfortunately the steps fail for me on step 1 with:

The CustomResourceDefinition "backendtlspolicies.gateway.networking.k8s.io" is invalid: status.storedVersions[0]: Invalid value: "v1alpha2": must appear in spec.versions

I'm trying to deploy on a cluster on my local network running k3s v1.30.2+k3s2, maybe the experimental channel isn't compatible with this?

Thanks, I attempted to follow these steps as well from 14-18 (since I already have a cluster running, with the whoami service deployed). These steps work for me and I can get the same 404 not found as you show in step 18. But I'm unable to adapt the remaining steps to configure the HTTPRoute. I suspect it is due to Traefik deploying its gateway on ports 9100, 9000, 8000, 8443 like this:

$ kubectl describe deployments.apps traefik --namespace traefik
Name:                   traefik
Namespace:              traefik
CreationTimestamp:      Fri, 09 Aug 2024 17:13:57 +0200
Labels:                 app.kubernetes.io/instance=traefik-traefik
                        app.kubernetes.io/managed-by=Helm
                        app.kubernetes.io/name=traefik
                        helm.sh/chart=traefik-30.0.2
Annotations:            deployment.kubernetes.io/revision: 3
                        field.cattle.io/publicEndpoints:
                          [{"addresses":["10.0.0.192","10.0.0.35","10.0.0.80"],"port":80,"protocol":"TCP","serviceName":"traefik:traefik","allNodes":false},{"addres...
                        meta.helm.sh/release-name: traefik
                        meta.helm.sh/release-namespace: traefik
Selector:               app.kubernetes.io/instance=traefik-traefik,app.kubernetes.io/name=traefik
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  0 max unavailable, 1 max surge
Pod Template:
  Labels:           app.kubernetes.io/instance=traefik-traefik
                    app.kubernetes.io/managed-by=Helm
                    app.kubernetes.io/name=traefik
                    helm.sh/chart=traefik-30.0.2
  Annotations:      prometheus.io/path: /metrics
                    prometheus.io/port: 9100
                    prometheus.io/scrape: true
  Service Account:  traefik
  Containers:
   traefik:
    Image:       docker.io/traefik:v3.1.0
    Ports:       9100/TCP, 9000/TCP, 8000/TCP, 8443/TCP
    Host Ports:  0/TCP, 0/TCP, 0/TCP, 0/TCP
    Args:
      --global.checknewversion
      --global.sendanonymoususage
      --entryPoints.metrics.address=:9100/tcp
      --entryPoints.traefik.address=:9000/tcp
      --entryPoints.web.address=:8000/tcp
      --entryPoints.websecure.address=:8443/tcp
      --api.dashboard=true
      --ping=true
      --metrics.prometheus=true
      --metrics.prometheus.entrypoint=metrics
      --providers.kubernetescrd
      --providers.kubernetesgateway
      --entryPoints.websecure.http.tls=true
      --log.level=INFO
    Liveness:   http-get http://:9000/ping delay=2s timeout=2s period=10s #success=1 #failure=3
    Readiness:  http-get http://:9000/ping delay=2s timeout=2s period=10s #success=1 #failure=1
    Environment:
      POD_NAME:        (v1:metadata.name)
      POD_NAMESPACE:   (v1:metadata.namespace)
    Mounts:
      /data from data (rw)
      /tmp from tmp (rw)
  Volumes:
   data:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  <unset>
   tmp:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  <unset>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  traefik-79d87d8b84 (0/0 replicas created), traefik-566cf58d7c (0/0 replicas created)
NewReplicaSet:   traefik-7c7587b647 (1/1 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  40m   deployment-controller  Scaled up replica set traefik-566cf58d7c to 1
  Normal  ScalingReplicaSet  40m   deployment-controller  Scaled down replica set traefik-79d87d8b84 to 0 from 1
  Normal  ScalingReplicaSet  4m4s  deployment-controller  Scaled up replica set traefik-7c7587b647 to 1
  Normal  ScalingReplicaSet  4m1s  deployment-controller  Scaled down replica set traefik-566cf58d7c to 0 from 1

While the gateway is configured to send traffic to ports 80 and 443 like this, so it is complaining that nothing is configured to listen:

$ kubectl describe gtw traefik
Name:         traefik
Namespace:    default
Labels:       <none>
Annotations:  <none>
API Version:  gateway.networking.k8s.io/v1
Kind:         Gateway
Metadata:
  Creation Timestamp:  2024-08-09T16:12:26Z
  Generation:          1
  Resource Version:    72117
  UID:                 bbcc6285-cdcc-4a47-9cd2-cb5250f3e8dd
Spec:
  Gateway Class Name:  traefik
  Listeners:
    Allowed Routes:
      Namespaces:
        From:  Same
    Name:      http
    Port:      80
    Protocol:  HTTP
    Allowed Routes:
      Namespaces:
        From:  Same
    Name:      https
    Port:      443
    Protocol:  HTTPS
    Tls:
      Certificate Refs:
        Group:      
        Kind:       Secret
        Name:       secret-tls
        Namespace:  default
      Mode:         Terminate
Status:
  Conditions:
    Last Transition Time:  2024-08-09T16:19:16Z
    Message:               All Listeners must be valid
    Observed Generation:   1
    Reason:                ListenersNotValid
    Status:                False
    Type:                  Accepted
  Listeners:
    Attached Routes:  0
    Conditions:
      Last Transition Time:  2024-08-09T16:19:16Z
      Message:               Cannot find entryPoint for Gateway: no matching entryPoint for port 80 and protocol "HTTP"
      Observed Generation:   1
      Reason:                PortUnavailable
      Status:                False
      Type:                  Accepted
    Name:                    http
    Supported Kinds:
    Attached Routes:  0
    Conditions:
      Last Transition Time:  2024-08-09T16:19:16Z
      Message:               Cannot find entryPoint for Gateway: no matching entryPoint for port 443 and protocol "HTTPS"
      Observed Generation:   1
      Reason:                PortUnavailable
      Status:                False
      Type:                  Accepted
    Name:                    https
    Supported Kinds:
Events:  <none>

I did enable debug logs on Traefik and got this potentially interesting message which probably shouldn't be skipped:

2024-08-09T14:56:52Z DBG github.com/traefik/traefik/v3/pkg/provider/kubernetes/gateway/kubernetes.go:250 > Skipping Kubernetes event kind *v1.HTTPRoute providerName=kubernetesgateway

Thanks again for your kind help trying to dig my way out of this! I'll try and start again from scratch carefully checking each step for success on Monday.

Try it with minikube because you need to open an external ip. I don't know with other cluster tools but with minikube you can minikube tunnel. Also, delete your cluster and create a new one. Sometimes that help.

Hey @rohanrehman,

Thank you for reaching out.

After discussing the issue with the team, it appears that the latest version of the Helm Chart has brought some breaking changes that can explain the issue you have faced.

I modified the command to fix the Helm version which should fix the issue.
I've fixed some indentations in the examples too.

I hope these modifications fix every problem, but if not, please follow up on this ticket.

1 Like

Are you saying that you were not able to clone the repository? If so, let me double check the link to the repository.

That's not the issue, I am able to access your repository just fine. I'm just not using minikube, I'm using a real 3-node k3s cluster on my local network, so I only followed from step 14 in your guide since I think the minikube, metallb and nginx steps are not relevant in my setup.

I've written up a separate forum post describing all my steps in detail here, would greatly appreciate any more help!