Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

Kubernetes Ingress: expose HTTP applications with Traefik

By updated

Improve this page

An Ingress is an HTTP routing rule: it tells a controller to send the requests that carry a given host and path to a given Service. This lesson has you install the Traefik controller on a kind cluster, publish two applications behind a single host name, switch to HTTPS, then break the configuration on purpose so you know where to look when nothing answers. It is for readers who already know how to create a Deployment and a Service and want to expose them outside the cluster.

What you will learn

  • Tell the Ingress resource apart from the controller that implements it, and install a controller
  • Choose between Ingress and Gateway API, and explain why ingress-nginx is no longer a choice for a new cluster
  • Write an Ingress with ingressClassName that routes two applications by path, then by host
  • Test an Ingress from your machine on the right port (8080 on kind, not 80)
  • Declare the tls block of an Ingress and place the kubernetes.io/tls Secret in the right namespace
  • Recognize that an annotation depends on the controller
  • Diagnose an Ingress that does not respond, from the HTTP code and the controller log

Prerequisites

You have read Kubernetes Services: you know what a Service is, its selector and its EndpointSlices. The versions used are kind 0.33.0, kubectl 1.37.0, nodes in v1.37.0 and Helm 4.3.0.

Helm is only used here to install the Traefik controller. The "Install Helm" section gives the installation in a few commands, and the Helm course (in French) teaches it in detail.

Some names in this lesson are in French on purpose, so that the commands and outputs stay those of the tested cluster: demo-expo means "expo-demo" (exposure demo), nexiste-pas "does-not-exist", par-hote "by-host", ingress-hotes.yaml "ingress-hosts.yaml" and demo-tls-ailleurs "demo-tls-elsewhere".

How does an Ingress work?

A request never enters the Ingress object: it enters the controller's Pod. The Ingress is only a configuration object stored in the Kubernetes API. The controller, here Traefik, watches the Ingress objects, the Services and the addresses of their Pods, rebuilds its routing table when they change, and sends each request to a Pod of the Service it names.

The following diagram shows the path of a request from your machine to the application on this lesson's cluster. Look at the dotted line: it is the only link between the Kubernetes API and the controller, and it is how the rules of the Ingress arrive.

A request leaves your machine, reaches port 80 of the worker node, then the Traefik Pod, which sends it to one of the application Pods designated by the Service. Traefik reads the Ingress objects, the Services and the Pod addresses from the Kubernetes API, shown by a dotted link.rules readYour machinecurl localhost:8080Worker nodeport 80Traefik Podthe controllerApplication Podsselected by the ServiceKubernetes APIIngress, Services and Pod addresses
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

Without a controller, an Ingress is accepted by the API but has no effect, and nothing warns you. A fresh kind cluster has none: kubectl get ingressclass answers No resources found.

Ingress or Gateway API: which one to choose?

The Ingress API is stable but frozen: Kubernetes adds no more features to it and recommends Gateway API for advanced needs (Kubernetes documentation). The two APIs coexist in a cluster and one controller can serve both. What Ingress cannot express (redirects, rewrites, traffic splitting) goes through annotations specific to each controller, whereas Gateway API describes it in its own resources.

Your needReasonable choice
Publish an application by host and path, with TLSIngress
Existing cluster already organized around IngressIngress, migration to plan
Redirect, weighted splitting, header matching without annotationsGateway API
Separate the cluster operator's role from the application teams' roleGateway API

Why not choose ingress-nginx?

The community project ingress-nginx has been archived since March 24, 2026: its repository is read-only and it no longer receives security fixes (announcement from SIG Network). For a new cluster, choose a maintained controller. This lesson uses Traefik, the controller of the course labs, which also serves Gateway API. Do not confuse ingress-nginx with F5's NGINX Ingress Controller, a separate and maintained product.

Install an Ingress Controller

Installing a controller takes two things: a cluster whose ports are reachable from your machine, then the controller itself. On kind, the nodes are Docker containers and nothing is published by default, so the first step is prepared before creating the cluster.

Prepare a kind cluster that publishes ports 8080 and 8443

This kind-expo.yaml file asks kind to link ports 8080 and 8443 of your machine to ports 80 and 443 of a single worker. The controller will then have to run on that worker.

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
extraPortMappings:
- containerPort: 80
hostPort: 8080
listenAddress: "0.0.0.0"
- containerPort: 443
hostPort: 8443
listenAddress: "0.0.0.0"
- role: worker
- role: worker
Terminal window
kind create cluster --name demo-expo --image kindest/node:v1.37.0@sha256:a1ed56cfb0e7b93589bdf97c8cd566405a265939e3620fc4f5de89adff580ae5 --config kind-expo.yaml
kubectl wait --for=condition=Ready nodes --all --timeout=120s
kubectl create namespace ws-ingress

The four nodes become Ready in about forty seconds. Then read the address of the worker that carries the ports, you will need it to install Traefik.

Terminal window
kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
demo-expo-control-plane Ready control-plane 24s v1.37.0 172.18.0.3 <none> Debian GNU/Linux 13 (trixie) 6.12.115+deb13.1-amd64 (amd64) containerd://2.3.4
demo-expo-worker Ready <none> 16s v1.37.0 172.18.0.4 <none> Debian GNU/Linux 13 (trixie) 6.12.115+deb13.1-amd64 (amd64) containerd://2.3.4
demo-expo-worker2 Ready <none> 16s v1.37.0 172.18.0.2 <none> Debian GNU/Linux 13 (trixie) 6.12.115+deb13.1-amd64 (amd64) containerd://2.3.4
demo-expo-worker3 Ready <none> 16s v1.37.0 172.18.0.5 <none> Debian GNU/Linux 13 (trixie) 6.12.115+deb13.1-amd64 (amd64) containerd://2.3.4

Look at the demo-expo-worker line: its internal address is 172.18.0.4 on this cluster. The addresses of your cluster may differ, and yours is the one to put in the install command.

The port to query is 8080, not 80

This is the mistake that makes you think something is broken when the cluster is healthy. Only the mapped worker publishes the ports, and on your machine they are called 8080 and 8443. The following command shows it.

Terminal window
docker port demo-expo-worker
80/tcp -> 0.0.0.0:8080
443/tcp -> 0.0.0.0:8443

As long as no controller is listening, both ports answer badly, each in its own way. On 8080, the connection is accepted and then cut; on port 80 of your machine, which nothing links to the cluster, it is refused.

Terminal window
curl -sS -m 3 -o /dev/null -w '%{http_code}\n' http://localhost:8080/
curl -sS -m 3 -o /dev/null -w '%{http_code}\n' http://localhost/
curl: (56) Recv failure: Connection reset by peer
000
curl: (7) Failed to connect to localhost port 80 after 0 ms: Could not connect to server
000

Remember the two curl error codes: 56 means the port is linked to the cluster but no controller answers there yet, and 7 means nothing listens on that port of your machine. If a response arrives on port 80 although you installed nothing, it comes from another service on your machine.

Install Helm

Helm is a tool that installs an application on Kubernetes from a package called a chart. It is only used here to install the controller: the guide Helm in 15 minutes (in French) explains it if you want to go further. The following commands download version 4.3.0 from the official site, check its SHA-256 sum, then install the binary in /usr/local/bin.

Terminal window
curl -fsSLo helm-v4.3.0-linux-amd64.tar.gz https://get.helm.sh/helm-v4.3.0-linux-amd64.tar.gz
curl -fsSLo helm-v4.3.0-linux-amd64.tar.gz.sha256sum https://get.helm.sh/helm-v4.3.0-linux-amd64.tar.gz.sha256sum
sha256sum -c helm-v4.3.0-linux-amd64.tar.gz.sha256sum
tar -xzf helm-v4.3.0-linux-amd64.tar.gz linux-amd64/helm
sudo install -m 0755 linux-amd64/helm /usr/local/bin/helm
helm version --short
helm-v4.3.0-linux-amd64.tar.gz: OK
v4.3.0+gbec5b06

Look at the OK line: it proves that the downloaded archive matches the published sum, so it has not been modified. If sha256sum answers FAILED, do not install it and download again. These commands apply to a Linux amd64 machine; for another system, take the matching archive from get.helm.sh.

Install Traefik

The following command installs Traefik v3.7.18, with Helm chart 41.6.0, and the image pinned by its digest. Replace 172.18.0.4 with the worker address you read earlier.

Terminal window
helm repo add traefik https://traefik.github.io/charts
helm repo update traefik
helm upgrade --install traefik traefik/traefik \
--namespace traefik --create-namespace --version 41.6.0 \
--set ports.web.nodePort=30080 \
--set ports.web.port=80 \
--set ports.websecure.nodePort=30443 \
--set ports.web.hostPort=80 \
--set ports.websecure.hostPort=443 \
--set 'nodeSelector.kubernetes\.io/hostname=demo-expo-worker' \
--set providers.kubernetesIngress.publishedService.enabled=false \
--set providers.kubernetesIngress.ingressEndpoint.ip=172.18.0.4 \
--set deployment.replicas=1 \
--set image.digest=sha256:9c437ac4f09ce6f4980a8544902d3475fdf70a1a7c578729581d2535dfa7d635 \
--set versionOverride=v3.7.18 \
--set-string 'podSecurityContext.sysctls[0].name=net.ipv4.ip_unprivileged_port_start' \
--set-string 'podSecurityContext.sysctls[0].value=0' \
--set providers.kubernetesGateway.enabled=false \
--set gateway.enabled=false \
--wait --timeout 6m
kubectl -n traefik rollout status deployment/traefik --timeout=300s

Three settings link Traefik to your machine. ports.web.hostPort=80 and ports.websecure.hostPort=443 make it listen on ports 80 and 443 of the node, the ones that extraPortMappings links to 8080 and 8443. nodeSelector places it on the only worker that carries these ports.

Two remarks on the command. The quotes around nodeSelector are necessary: without them, the shell swallows the backslash and Helm rejects the option. As for ingressEndpoint.ip, it sets the address that Traefik will copy into the ADDRESS column of the Ingresses.

The installation takes about twenty seconds. The chart notes show a warning about a "non-standard version", v3.7.13. That is the chart's default version, quoted despite versionOverride: the image actually started is the one from the digest, which the following command checks.

Terminal window
kubectl -n traefik get pods -o wide
kubectl -n traefik get deployment traefik -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
traefik-65f84d5855-b5mxs 1/1 Running 0 19s 10.244.1.2 demo-expo-worker <none> <none>
docker.io/traefik@sha256:9c437ac4f09ce6f4980a8544902d3475fdf70a1a7c578729581d2535dfa7d635

Check two things in this output: a single traefik Pod is 1/1 Running, on demo-expo-worker, and the image carries the digest you asked for. Then look at the chart's Service, and the classes it created.

Terminal window
kubectl -n traefik get svc traefik
kubectl get ingressclass
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
traefik LoadBalancer 10.96.125.80 <pending> 80:30080/TCP,443:30443/TCP 19s
NAME CONTROLLER PARAMETERS AGE
traefik (default) traefik.io/ingress-controller <none> 19s

The chart's Service is of type LoadBalancer and stays at EXTERNAL-IP <pending>, since kind has no load balancer. This does not matter here, because access goes through the hostPort, not through the Service. A traefik IngressClass was created by the chart, with the controller traefik.io/ingress-controller. You therefore do not have to write it.

The chart also marks it as the default class, which (default) indicates. According to the Kubernetes documentation, an Ingress without ingressClassName is then handled by the default class.

Traefik goes further: it also serves an Ingress without a class when its own class is not marked as default, a behavior that depends on the controller and not on Kubernetes. Still write the class name in every Ingress, so that the choice of controller depends neither on the cluster setting nor on a Traefik quirk.

One last check tells you whether the controller answers, even before any rule exists.

Terminal window
curl -sS -i -m 3 http://localhost:8080/
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Thu, 12 Nov 2026 09:00:38 GMT
Content-Length: 19
404 page not found

A 404 page not found in text/plain is Traefik's answer when no rule matches. This code is a good sign at this stage: port 8080 does reach the controller, only a rule is missing.

Create your first Ingress

An Ingress does not name Pods but a Service, which must therefore exist before it. Creating the Ingress first produces no error when the manifest is applied, but requests fail until the Service and its Pods exist. The order is therefore the application, its Service, then the Ingress.

Prepare the application and the Service

Two nginx applications each serve a page that carries their name, in the ws-ingress namespace. Each ConfigMap holds the index.html file, mounted in a folder named after the application (/a or /b), which tells you who answered.

First create the two ConfigMaps. The manifest of the Deployments and Services that follows is saved in the apps.yaml file, which the kubectl apply -f apps.yaml command will then read.

Terminal window
kubectl -n ws-ingress create configmap page-a --from-literal=index.html='application A'
kubectl -n ws-ingress create configmap page-b --from-literal=index.html='application B'
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-a
namespace: ws-ingress
spec:
replicas: 1
selector:
matchLabels:
app: app-a
template:
metadata:
labels:
app: app-a
spec:
containers:
- name: nginx
image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb
ports:
- containerPort: 80
volumeMounts:
- name: page
mountPath: /usr/share/nginx/html/a
volumes:
- name: page
configMap:
name: page-a
---
apiVersion: v1
kind: Service
metadata:
name: app-a
namespace: ws-ingress
spec:
selector:
app: app-a
ports:
- port: 80
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-b
namespace: ws-ingress
spec:
replicas: 1
selector:
matchLabels:
app: app-b
template:
metadata:
labels:
app: app-b
spec:
containers:
- name: nginx
image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb
ports:
- containerPort: 80
volumeMounts:
- name: page
mountPath: /usr/share/nginx/html/b
volumes:
- name: page
configMap:
name: page-b
---
apiVersion: v1
kind: Service
metadata:
name: app-b
namespace: ws-ingress
spec:
selector:
app: app-b
ports:
- port: 80
targetPort: 80

In this manifest, each Service's port, 80, is the one the Ingress will cite; the targetPort is the one the container listens on.

Terminal window
kubectl apply -f apps.yaml
kubectl -n ws-ingress rollout status deployment/app-a deployment/app-b --timeout=90s
kubectl -n ws-ingress get endpointslices
deployment.apps/app-a created
service/app-a created
deployment.apps/app-b created
service/app-b created
Waiting for deployment "app-a" rollout to finish: 0 of 1 updated replicas are available...
deployment "app-a" successfully rolled out
deployment "app-b" successfully rolled out
NAME ADDRESSTYPE PORTS ENDPOINTS AGE
app-a-pp6vz IPv4 80 10.244.2.2 13s
app-b-7dpgg IPv4 80 10.244.3.2 13s

In the EndpointSlices, check that each Service has a Pod address in the ENDPOINTS column. A Service without an address will serve nothing, even behind a correct Ingress.

Create the Ingress

This Ingress publishes the two applications under the demo.test host: paths that start with /a go to app-a, those that start with /b go to app-b. The ingressClassName field names the traefik class, so the controller that must handle it. Save the manifest in the ingress-demo.yaml file.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: demo
namespace: ws-ingress
spec:
ingressClassName: traefik
rules:
- host: demo.test
http:
paths:
- path: /a
pathType: Prefix
backend:
service:
name: app-a
port:
number: 80
- path: /b
pathType: Prefix
backend:
service:
name: app-b
port:
number: 80
Terminal window
kubectl apply -f ingress-demo.yaml
kubectl -n ws-ingress get ingress demo
ingress.networking.k8s.io/demo created
NAME CLASS HOSTS ADDRESS PORTS AGE
demo traefik demo.test 172.18.0.4 80 0s

The CLASS column repeats the class, HOSTS the host, and ADDRESS carries 172.18.0.4, the address you passed to ingressEndpoint.ip. This address is a node's, not a cloud load balancer's. It is published by Traefik, which shows that it has seen the Ingress, but it does not prove that requests succeed: the troubleshooting section shows an Ingress that keeps it while its class is wrong.

Test the access

Routing is done on the host name, so the test must send demo.test even though this name exists in no DNS. Two ways allow it: the Host header, or the --resolve option of curl, which maps the name to 127.0.0.1 for that single command. Here the port stays 8080.

Terminal window
curl -sS -i -m 5 -H 'Host: demo.test' http://localhost:8080/a/
curl -sS -m 5 -H 'Host: demo.test' http://localhost:8080/b/
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 13
Content-Type: text/html
Date: Thu, 12 Nov 2026 09:00:51 GMT
Etag: "6af58036-d"
Last-Modified: Thu, 12 Nov 2026 09:00:38 GMT
Server: nginx/1.30.5
application A
application B

Look at the body of each response: application A on /a/ and application B on /b/ prove that each path reaches the right application. The Server: nginx/1.30.5 line is the backend's, not the controller's: Traefik does not replace it.

Add two controls to check that routing really depends on the host.

Terminal window
curl -sS -m 5 -o /dev/null -w '%{http_code}\n' http://localhost:8080/a/
curl -sS -m 5 --resolve demo.test:8080:127.0.0.1 http://demo.test:8080/a/
404
application A

Without the demo.test host, the same URL returns 404. With --resolve, the request leaves under the name demo.test and the page answers. One last trap concerns the request to /a without a trailing slash.

Terminal window
curl -sS -i -m 5 -H 'Host: demo.test' http://localhost:8080/a
HTTP/1.1 301 Moved Permanently
Content-Length: 169
Content-Type: text/html
Date: Thu, 12 Nov 2026 09:00:52 GMT
Location: http://demo.test/a/
Server: nginx/1.30.5
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.30.5</center>
</body>
</html>

This redirect comes from nginx, the backend, which adds the trailing slash to a folder. Look at the Location line: it has no port 8080, so a client that followed the redirect would aim at port 80 and fail. Always test with the trailing slash.

Path routing

Under a single host, several paths target different Services, which lets you expose an API and its web interface without a dedicated subdomain. The path is passed as is to the backend. That is why this lesson's applications serve their page under /a and /b: if they served it at the root, /a/ would be unknown to them and they would answer 404.

The pathType field decides what "match" means. With Prefix, /a matches /a, /a/ and /a/page.html. With Exact, only /a matches. Choose Prefix unless you need otherwise (definition of path types in the Kubernetes documentation).

A path you did not declare leads nowhere. The following test shows it on /c/, with the correct host.

Terminal window
curl -sS -i -m 5 -H 'Host: demo.test' http://localhost:8080/c/
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Thu, 12 Nov 2026 09:00:52 GMT
Content-Length: 19
404 page not found

This 404 comes from Traefik, not from the application: the body is a 19-byte plain text, without nginx's HTML page. It signals a request that matches no rule, not a failed backend.

Multi-domain routing

An Ingress accepts several host entries, each with its own paths. In the following example, a.demo.test publishes app-a on /a, and b.demo.test publishes app-b on /b. For a set of applications run by different teams, prefer one Ingress per application: deleting a shared Ingress cuts all its rules at once.

Save this manifest in the ingress-hotes.yaml file.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: par-hote
namespace: ws-ingress
spec:
ingressClassName: traefik
rules:
- host: a.demo.test
http:
paths:
- path: /a
pathType: Prefix
backend:
service:
name: app-a
port:
number: 80
- host: b.demo.test
http:
paths:
- path: /b
pathType: Prefix
backend:
service:
name: app-b
port:
number: 80
Terminal window
kubectl apply -f ingress-hotes.yaml
curl -sS -m 5 --resolve a.demo.test:8080:127.0.0.1 http://a.demo.test:8080/a/
curl -sS -m 5 --resolve a.demo.test:8080:127.0.0.1 http://a.demo.test:8080/b/ -o /dev/null -w '%{http_code}\n'
ingress.networking.k8s.io/par-hote created
application A404

The first call returns application A and the second 404, stuck together on the same line because the body of the first response has no line ending. The 404 is normal: the a.demo.test host only publishes /a. A request is routed only if both its host and its path match a rule.

Troubleshooting: an Ingress that does not respond

A failing Ingress is diagnosed from the outside in: does the controller answer, did it keep the rule, does the Service have Pods. The HTTP code already tells you at which stage the chain breaks, which saves you from rereading the YAML when the fault is a Service selector.

Check the Ingress status

The first reflex is to read kubectl get ingress and kubectl describe ingress, but they do not tell everything. The following test gives the demo Ingress a class that does not exist, then reads what the cluster says about it.

Terminal window
kubectl -n ws-ingress patch ingress demo --type merge -p '{"spec":{"ingressClassName":"nexiste-pas"}}'
kubectl -n ws-ingress get ingress demo
kubectl -n ws-ingress describe ingress demo
ingress.networking.k8s.io/demo patched
NAME CLASS HOSTS ADDRESS PORTS AGE
demo nexiste-pas demo.test 172.18.0.4 80 4s
Name: demo
Labels: <none>
Namespace: ws-ingress
Address: 172.18.0.4
Ingress Class: nexiste-pas
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
demo.test
/a app-a:80 (10.244.2.2:80)
/b app-b:80 (10.244.3.2:80)
Annotations: <none>
Events: <none>

The patch is accepted without error, Events is empty and ADDRESS keeps 172.18.0.4. Nothing in the object says that nobody handles it anymore. The proof is in the HTTP response: one to two seconds after the patch, the request returns 404.

Terminal window
curl -sS -m 5 -o /dev/null -w '%{http_code}\n' -H 'Host: demo.test' http://localhost:8080/a/
404

Put the correct class back, and the route returns within a few seconds.

Terminal window
kubectl -n ws-ingress patch ingress demo --type merge -p '{"spec":{"ingressClassName":"traefik"}}'
curl -sS -m 5 -o /dev/null -w '%{http_code}\n' -H 'Host: demo.test' http://localhost:8080/a/
ingress.networking.k8s.io/demo patched
200

Depending on when the request leaves, the first response may still be 404: Traefik takes one to two seconds to reread the Ingress. Wait two seconds and try again before concluding.

The ADDRESS column therefore does not prove that an Ingress is handled. The proof that counts is a request that succeeds.

Check the Ingress Controller

The controller says what it is doing in its log, which you read with kubectl logs. A configuration error of an Ingress appears there, whereas it is absent from the object's events. The TLS section gives a real example.

Terminal window
kubectl -n traefik logs deploy/traefik --tail=20

If the controller itself does not start, look at its Pods and their events with kubectl -n traefik get pods and kubectl -n traefik describe pod. These are the same steps as for any application.

Common errors

The returned code tells you where the failure is. A Traefik 404 means that no rule matches, a 503 that the rule exists but the Service has no Pod.

To get the 503, remove the Pods of app-a by breaking the selector of its Service. The EndpointSlices empty out, and Traefik answers.

Terminal window
kubectl -n ws-ingress patch service app-a --type merge -p '{"spec":{"selector":{"app":"nexiste-pas"}}}'
kubectl -n ws-ingress get endpointslices -l kubernetes.io/service-name=app-a
curl -sS -m 5 -i -H 'Host: demo.test' http://localhost:8080/a/
service/app-a patched
NAME ADDRESSTYPE PORTS ENDPOINTS AGE
app-a-pp6vz IPv4 <unset> <unset> 20s
HTTP/1.1 503 Service Unavailable
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Thu, 12 Nov 2026 09:01:01 GMT
Content-Length: 20
no available server

The EndpointSlice has neither port nor address anymore, and Traefik answers 503 Service Unavailable with no available server. Put the original selector back to continue.

Terminal window
kubectl -n ws-ingress patch service app-a --type merge -p '{"spec":{"selector":{"app":"app-a"}}}'

The table summarizes the symptoms met in this lesson.

SymptomLikely causeWhere to look
curl: (7) on port 80You aim at port 80 of your machine, linked to nothingUse 8080 on this cluster
curl: (56) on port 8080The port is linked but no controller listenskubectl -n traefik get pods
404 page not found in plain textNo rule matches: host, path or classkubectl describe ingress, then ingressClassName
503, no available serverThe Service has no Podkubectl get endpointslices -l kubernetes.io/service-name=<service>
No event, 404 after a class changeNo controller carries this classkubectl get ingressclass

Configure Ingress with TLS

The tls block of an Ingress names a Secret of type kubernetes.io/tls, which must be in the same namespace as the Ingress. The controller reads the certificate and the key there, and serves them for the listed hosts. For the test, a self-signed certificate is enough. In production, cert-manager creates and renews this Secret for you.

Terminal window
openssl req -x509 -newkey rsa:2048 -nodes -days 1 -keyout tls.key -out tls.crt -subj "/CN=demo.test" -addext "subjectAltName=DNS:demo.test"
kubectl -n ws-ingress create secret tls demo-tls --cert=tls.crt --key=tls.key
kubectl -n ws-ingress get secret demo-tls
secret/demo-tls created
NAME TYPE DATA AGE
demo-tls kubernetes.io/tls 2 0s

The Secret has the type kubernetes.io/tls and two data entries, the certificate and the key. Save the TLS Ingress in the ingress-tls.yaml file. Delete the two previous Ingresses so you keep only this one, then apply it.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: demo-tls
namespace: ws-ingress
spec:
ingressClassName: traefik
tls:
- hosts:
- demo.test
secretName: demo-tls
rules:
- host: demo.test
http:
paths:
- path: /a
pathType: Prefix
backend:
service:
name: app-a
port:
number: 80
Terminal window
kubectl delete ingress demo par-hote -n ws-ingress
kubectl apply -f ingress-tls.yaml
curl -sS -k -m 5 --resolve demo.test:8443:127.0.0.1 https://demo.test:8443/a/ -v 2>&1 | grep -E 'subject|^< HTTP|application'
ingress.networking.k8s.io "demo" deleted from ws-ingress namespace
ingress.networking.k8s.io "par-hote" deleted from ws-ingress namespace
ingress.networking.k8s.io/demo-tls created
* subject: CN=demo.test
< HTTP/2 200
application A

Look at the subject: CN=demo.test line: the certificate presented is yours, and the page answers over HTTP/2. Without the -k option, curl rejects this certificate because no authority signed it.

Terminal window
curl -sS -m 5 --resolve demo.test:8443:127.0.0.1 https://demo.test:8443/a/
curl: (60) SSL certificate problem: self-signed certificate
More details here: https://curl.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the webpage mentioned above.

Enabling TLS does not forbid port 80 either. Query the same Ingress over plain HTTP: the page still answers, without a redirect to HTTPS.

Terminal window
curl -sS -i -m 5 -H 'Host: demo.test' http://localhost:8080/a/ | head -5
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 13
Content-Type: text/html
Date: Thu, 12 Nov 2026 09:01:08 GMT

The tls block adds HTTPS, it does not remove HTTP. Redirecting HTTP to HTTPS takes a setting specific to the controller, for example Traefik's RedirectScheme Middleware (Traefik documentation). The guide Traefik on Kubernetes (in French) shows how to attach a middleware to a route.

What happens if the Secret is in another namespace?

A Secret placed in a different namespace than the Ingress is not read, and the failure stays quiet. Create a demo-tls-ailleurs Secret in the ws-ingress-b namespace and have the Ingress cite it.

Terminal window
kubectl create namespace ws-ingress-b
kubectl -n ws-ingress-b create secret tls demo-tls-ailleurs --cert=tls.crt --key=tls.key
kubectl -n ws-ingress patch ingress demo-tls --type merge -p '{"spec":{"tls":[{"hosts":["demo.test"],"secretName":"demo-tls-ailleurs"}]}}'
curl -sS -k -m 5 --resolve demo.test:8443:127.0.0.1 https://demo.test:8443/a/ -v 2>&1 | grep -E 'subject|issuer|^< HTTP|SSL|alert'
namespace/ws-ingress-b created
secret/demo-tls-ailleurs created
ingress.networking.k8s.io/demo-tls patched
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / X25519MLKEM768 / RSASSA-PSS
* subject: CN=TRAEFIK DEFAULT CERT
* issuer: CN=TRAEFIK DEFAULT CERT
* SSL certificate verify result: self-signed certificate (18), continuing anyway.
< HTTP/2 200

The patch is accepted, the page answers 200, but the certificate is no longer yours: Traefik serves its own certificate, CN=TRAEFIK DEFAULT CERT. With -k, nothing looks broken, and a client that verifies the certificate would refuse the connection. The error is only in the controller's log.

Terminal window
kubectl -n traefik logs deploy/traefik --tail=-1 | grep -i -E 'secret|demo-tls|certificate' | tail -10
2026-11-12T09:01:04Z INF Updated ingress status ingress=demo-tls namespace=ws-ingress
2026-11-12T09:01:08Z ERR Error configuring TLS error="secret ws-ingress/demo-tls-ailleurs does not exist" ingress=demo-tls namespace=ws-ingress providerName=kubernetes

Read the ERR line: Traefik looks for the demo-tls-ailleurs Secret in ws-ingress, the Ingress's namespace, and does not find it. Writing secretName: ws-ingress-b/demo-tls-ailleurs is not a solution, the API rejects this name (spec.tls[0].secretName: Invalid value). The solution is to create the Secret in the Ingress's namespace.

Terminal window
kubectl -n ws-ingress patch ingress demo-tls --type merge -p '{"spec":{"tls":[{"hosts":["demo.test"],"secretName":"demo-tls"}]}}'
curl -sS -k -m 5 --resolve demo.test:8443:127.0.0.1 https://demo.test:8443/a/
ingress.networking.k8s.io/demo-tls patched
application A

A default certificate that answers 200 therefore proves nothing: read the subject of the presented certificate (openssl s_client or curl -v), not only the HTTP code.

Why are annotations not portable from one controller to another?

Everything the Ingress specification does not cover, such as redirects, address filtering or rewrites, is set through annotations or objects specific to the controller. An annotation from another controller is silently ignored. The following example puts on the Ingress an ingress-nginx annotation, which Traefik does not know.

Terminal window
kubectl -n ws-ingress annotate ingress demo-tls nginx.ingress.kubernetes.io/rewrite-target=/ --overwrite
kubectl -n ws-ingress describe ingress demo-tls | grep -A3 Annotations
curl -sS -k -m 5 --resolve demo.test:8443:127.0.0.1 https://demo.test:8443/a/
ingress.networking.k8s.io/demo-tls annotated
Annotations: nginx.ingress.kubernetes.io/rewrite-target: /
Events: <none>
application A

The annotation is accepted, no event is emitted, and the response is unchanged: if the rewrite to / had applied, nginx would have served its welcome page. Annotations therefore make an Ingress hard to port from one controller to another: changing controller forces you to rewrite them, and nothing signals the ones that no longer work. Gateway API describes these behaviors in the API itself.

How do you clean up the lesson's cluster?

Delete the namespaces, the Helm release, then the cluster.

Terminal window
kubectl delete namespace ws-ingress ws-ingress-b
helm uninstall traefik --namespace traefik
kind delete cluster --name demo-expo

Hands-on practice

The two labs of this lesson rely on the same steps, without redoing the demonstration. The first publishes two applications already running under a single host name, app.local, and is validated on what each path answers, including an undeclared path that must lead to neither of them. The second starts from a site that already answers over HTTPS, but with the controller's default certificate: the task is to serve a certificate that really names the host, without breaking the route.

These labs run on a kubeadm virtual machine, with the same Traefik as in the demonstration. Two things differ. Requests go through ports 30080 and 30443 of the node, not through localhost:8080. The traefik class is not marked as default there (isDefaultClass=false): Kubernetes therefore assigns no class to an Ingress that names none, and the lab requires you to name yours, so that the choice of controller is explicit.

As in the demonstration, kubectl get ingress shows the node's address in the ADDRESS column there.

Key takeaways

  • An Ingress is a routing rule; without a controller, it is accepted by the API and stays without effect. A fresh kind cluster has neither a controller nor an IngressClass: Traefik's Helm chart creates the traefik IngressClass.
  • Always write ingressClassName, even if the class is marked as default on your cluster.
  • On this kind cluster, your machine queries port 8080 (HTTP) or 8443 (HTTPS), never port 80 or 443 of your machine.
  • A request is routed only if its host and path match a rule; otherwise Traefik answers 404 page not found, and 503 when the Service has no Pod.
  • ADDRESS does not prove that an Ingress is served: only a request that succeeds proves it.
  • The kubernetes.io/tls Secret must be in the Ingress's namespace; otherwise Traefik serves its default certificate, with a 200, and the error is only in its log.
  • An annotation from another controller is ignored without a message: Gateway API avoids this dependency.
  • ingress-nginx has been archived since March 24, 2026: for a new cluster, pick a maintained controller such as Traefik.

FAQ: frequently asked questions about Ingress

These questions take up the points of the lesson: the role of the controller, the choice between Ingress and Gateway API, HTTPS and the 404 and 503 codes.

Test your knowledge

Seven questions drawn from the bank: role of the controller, routing by host and by path, TLS, the ingressClassName field and the port to query on kind.

Knowledge check

Check what you have learned with this interactive quiz

7 questions
5 min
80% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer