In this lab, you install the Ingress controller Traefik and make the message board from 4.2 reachable by a host name.
Step 1: Install Traefik
Create the directories of this lab and change into it:
mkdir -p ~/labs/5.1/traefik
cd ~/labs/5.1
Create the file values.yaml with the settings for Traefik in ~/labs/5.1/traefik, a directory of its
own, because the Clean Up deletes all manifests in ~/labs/5.1 at once:
Pulled: ghcr.io/traefik/helm/traefik:41.7.1
Digest: sha256:ce4608f8ad8fff14b6e335f525b1f430798c91c0b74fe0751d8e3f00c97671f0
NAME: traefik
LAST DEPLOYED: Tue Oct 13 17:00:37 2026
NAMESPACE: traefik
STATUS: deployed
REVISION: 1
DESCRIPTION: Install complete
TEST SUITE: None
NOTES:
traefik with docker.io/traefik:v3.7.14 has been deployed successfully on traefik namespace!
Wait about 10 seconds and list the Pod and the Service:
kubectl get pods -n traefik
NAME READY STATUS RESTARTS AGE
traefik-d6b4b748b-k9fs4 1/1 Running 0 10s
If the Pod isn’t 1/1 yet, wait a moment and repeat the command.
kubectl get services -n traefik
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
traefik NodePort 10.43.248.200 <none> 80:31337/TCP 10s
Send a request to Traefik:
curl http://localhost:31337
404 page not found
Explanation
Traefik is an Ingress controller: a reverse proxy that runs as a Pod and forwards each request according to the
rules of the Ingress resources in the cluster.
By default, the chart creates a LoadBalancer Service, which would stay <pending> in your cluster. The values turn it
into a NodePort Service on port 31337, which 2.1 made reachable from your machine. They also leave out the HTTPS port
websecure, because the labs use plain HTTP.
The 404 comes from Traefik itself: it received the request, but there’s no rule yet that tells it where to forward
it.
Step 2: Expose the Message Board
Create the file messages-ingress.yaml in ~/labs/5.1 with a rule for the host name
messages.localhost:
Apply it and list the Ingresses in the namespace of the message board:
kubectl apply -f messages-ingress.yaml
ingress.networking.k8s.io/messages created
kubectl get ingress -n messages-dev
NAME CLASS HOSTS ADDRESS PORTS AGE
messages traefik messages.localhost 80 0s
Names ending in .localhost
Chrome, Edge, Firefox and curl send every name ending in .localhost to your own machine, without a DNS entry
(curl in WSL needs the entry below). If your browser can’t find the address, open it in one of them.
WSL: add the names to /etc/hosts
In WSL, curl may ask the DNS server of Windows for these names, which doesn’t know them, and fails with
Could not resolve host. Add the names of this lab to /etc/hosts once:
echo"127.0.0.1 messages.localhost other.localhost whoami.localhost gateway.localhost"| sudo tee -a /etc/hosts
WSL rewrites /etc/hosts when it restarts. If the names stop working after a restart, run the command again.
Open http://messages.localhost:31337 in your browser. The message board shows the message from 4.2. Post another
one, e.g. Hello Ingress, then read the messages through the Ingress:
The Ingress has one rule: requests for the host messages.localhost with a path that starts with / (so every
path) go to port 80 of the Service frontend. The frontend still forwards /api/ to the backend, as in 3.1.
Column
Meaning
CLASS
The Ingress controller in charge. The chart made Traefik the default, so the manifest doesn’t name it
HOSTS
The host names the rules match
ADDRESS
Stays empty in your cluster: there’s no load balancer that could provide an address
namespace: messages-dev in the metadata puts the Ingress next to the frontend, because an Ingress forwards only
to Services in its own namespace. Traefik reads Ingresses from every namespace, and the NodePort 30088 of the frontend
keeps working as well.
Step 3: Route by Path
Replace the content of messages-ingress.yaml with a second path: requests for /health go straight
to the backend.
If you get the 404 Not Found page of nginx instead, Traefik hasn’t picked up the new path yet. Wait a moment and
repeat the command.
Send a request for a host without a rule:
curl http://other.localhost:31337
404 page not found
Explanation
Both paths belong to the same host, and both match /health: / matches every path. When several rules match,
Traefik takes the longest one, so /health goes to the backend and every other path to the frontend. Before this
step, /health went to the frontend, and nginx didn’t know it.
Traefik spreads the requests over the three backend Pods, so the answers come from different Pods. A host without a rule
gets the 404 from Step 1. One Ingress controller on one port can serve any number of applications and tells them
apart by host name and path.
Optional Tasks
Finished early? Try these tasks. The following labs don’t depend on them. Each task lists the commands you need.
Open the solution if you get stuck.
Task 1: Who Am I
Run the image traefik/whoami:v1.12.0 from 2.6 with a Deployment and a Service
on port 80 in the namespace default. Make it reachable at http://whoami.localhost:31337 with an Ingress, then list
the Ingresses of all namespaces.
If you get 404 page not found, wait a few seconds and repeat the command.
kubectl get ingress -A
NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
default whoami traefik whoami.localhost 80 3s
messages-dev messages traefik messages.localhost 80 27s
Two applications in two namespaces share the port 31337. Traefik tells them apart by the host name. whoami shows
the request as it arrived: Host is the name Traefik routed by, X-Forwarded-Server the Traefik Pod that
forwarded it.
Task 2: Control Room
Traefik shows its routes in a dashboard. Turn it on with the chart value ingressRoute.dashboard.enabled: true in a
second values file dashboard.yaml in ~/labs/5.1/traefik. Open http://localhost:8080/dashboard/
through a port forward to port 8080 of the Deployment traefik and find the routes of your Ingress.
Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080
Open http://localhost:8080/dashboard/ in your browser. Under HTTP Routers, you find the two rules of your
Ingress, e.g. Host("messages.localhost") && PathPrefix("/health") with the service messages-dev-backend-8000.
Every rule appears a second time with the prefix websecure-, for the HTTPS port that you left out. Stop the port
forward with Ctrl+C.
The dashboard shows what Traefik made of your Ingress: a router per rule, and a service per Service and port. Pass
values.yaml again with every upgrade: as soon as you pass a values file, helm upgrade starts from
the defaults of the chart. Without it, Traefik would get a LoadBalancer Service again.
Task 3: The Successor
The Gateway API is the successor of Ingress. Make the message board reachable at http://gateway.localhost:31337 with
an HTTPRoute in the namespace messages-dev that attaches to the Gateway traefik-gateway in the namespace
traefik.
The resource types of the Gateway API aren’t part of Kubernetes. Install them from
https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.5.1/standard-install.yaml. Then
let the chart create the Gateway with a third values file gateway.yaml in ~/labs/5.1/traefik:
Pulled: ghcr.io/traefik/helm/traefik:41.7.1
...
Release "traefik" has been upgraded. Happy Helming!
...
⚠️ DEPRECATION WARNING: Gateway API CRDs will no longer be shipped with this chart in a future major version.
You will need to install them yourself before deploying Traefik v3.7:
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.5.1/standard-install.yaml
The warning names the resource types you already installed. Check the Gateway:
kubectl get gateway -n traefik
NAME CLASS ADDRESS PROGRAMMED AGE
traefik-gateway traefik True 15s
If PROGRAMMED isn’t True yet, wait a moment and repeat the command. Create the file
messages-route.yaml in ~/labs/5.1:
If you get 404 page not found, wait a few seconds and repeat the command.
An Ingress describes everything in one resource. The Gateway API splits it in two: the Gateway is the entry point,
created by the chart in the namespace traefik and usually owned by the team that runs the cluster. The HTTPRoute
belongs to the application, lives in its namespace and attaches to the Gateway with parentRefs. By default, a
Gateway accepts routes only from its own namespace. namespacePolicy.from: All opens it to every namespace.
Clean Up
Delete the Ingress and everything the optional tasks created from the files in ~/labs/5.1:
kubectl delete -f ~/labs/5.1/
ingress.networking.k8s.io "messages" deleted from messages-dev namespace
httproute.gateway.networking.k8s.io "messages" deleted from messages-dev namespace
deployment.apps "whoami" deleted from default namespace
service "whoami" deleted from default namespace
ingress.networking.k8s.io "whoami" deleted from default namespace
The lines for the HTTPRoute and whoami appear only if you did Task 1 or 3. If you did Task 2 or 3, reset Traefik to
the values from Step 1: