In this tutorial, you will learn how to deploy a Traefik ingress controller on your Kubernetes cluster. You will learn more about Traefik, its benefits and how to set it up and configure it on Kubernetes using Helm.
We will be using a Platform9 Managed Kubernetes cluster for this tutorial. However, you can use this tutorial to deploy Traefik on any Kubernetes cluster of your choice.
Traefik Kubernetes Ingress is a modern, full-featured ingress controller for Kubernetes with powerful capabilities out of the box. Traefik installs as one or more pods that represent the Traefik controller, ingress proxies, and mesh proxies in your Kubernetes cluster.
Once your Kubernetes cluster is up and running, you need to add the helm repository for Traefik to the cluster.
xxxxxxxxxxhelm repo add traefik https://helm.traefik.io/traefikxxxxxxxxxx"traefik" has been added to your repositoriesOnce you have added the helm repository, perform a generic repository update for your helm repositories to fetch the latest upstream updates for the newly-added traefik chart repository.
xxxxxxxxxxhelm repo updatexxxxxxxxxxHang tight while we grab the latest from your chart repositories......Successfully got an update from the "traefik" chart repositoryInstall the Traefik chart, ensuring you are scoped to the desired namespace.
xxxxxxxxxxhelm install traefik traefik/traefikxxxxxxxxxxNAME: traefikLAST DEPLOYED: Thu Apr 1 12:38:31 2021NAMESPACE: defaultSTATUS: deployedREVISION: 1TEST SUITE: NoneOnce Traefik is installed, validate that the resources were deployed correctly, e.g. the Traefik service was created, the Traefik pod is running, etc.
xxxxxxxxxxkubectl get svc -l app.kubernetes.io/name=traefikxxxxxxxxxxNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEtraefik LoadBalancer 10.21.12.102 10.0.0.4 80:30416/TCP,443:30724/TCP 2m5sxxxxxxxxxxkubectl get po -l app.kubernetes.io/name=traefikxxxxxxxxxxNAME READY STATUS RESTARTS AGEtraefik-5f896b6cc7-q56xl 1/1 Running 0 2m7sThe PMK App Catalog can simplify installations and allow you to modify the application using the UI instead of working from the command line. We will walk through an installation using the App Catalog below.
Start out by navigating to the Apps section. Select + Add New Repository.

Then we will name the repository, in our example we name it Traefik. The URL is going to be the Helm Repository that hosts the charts we need. For Traefik we will use https://helm.traefik.io/traefik. Save and move on to the next step.

Now the available applications will show up under the App Catalog section. We are going to deploy Traefik. Select Deploy on the Traefik tile. This will take us to the configuration of our application.

In the Deploy Application page we can name our deployment, select the cluster, namespace, version, and modify the values associated with the deployment. We will name the deployment traefik and select the cluster we want to use, then select the default namespace. The version will be set to the latest version as of this post: 10.9.1.
If you want to access the Dashboard for Traefik using an IP address and port 9000 then we will need to modify the values file. The Dashboard will deploy with "traefik" as the default entrypoint, which means we need to update the expose option from false to true. Once modified we will select Deploy.
xxxxxxxxxx"traefik": { "expose": true, "exposedPort": 9000, "port": 9000, "protocol": "TCP"If you want to modify the Dashboard IngressRoute to use Web, which is exposed by default and will allow use of port 80, then don't modify the deployment. We will update the IngressRoute after the Deployment has finished and add a Host so that traffic is routed based on "demo.pf9.io". |

By default, the helm chart and PMK App Catalog deploy an IngressRoute for the Traefik dashboard.
xxxxxxxxxxapiVersiontraefik.containo.us/v1alpha1kindIngressRoutemetadata annotations helm.sh/hookpost-install,post-upgrade labels app.kubernetes.io/instancetraefik app.kubernetes.io/managed-byHelm app.kubernetes.io/nametraefik helm.sh/charttraefik-9.18.1 ... nametraefik-dashboard namespacetraefikspec entryPointstraefik routeskindRule matchPathPrefix(`/dashboard`) || PathPrefix(`/api`) serviceskindTraefikService nameapi@internalBy default the entryPoint for traefik is not exposed, which means we'll either need to expose the endpoint - like we did above - or change the endpoint to web and add a Host to the match field. This assumes we want to access the Dashboard via port 80 using a domain instead of an IP address.
xxxxxxxxxxkubectl edit ingressroute traefik-dashboardxxxxxxxxxxapiVersiontraefik.containo.us/v1alpha1kindIngressRoutemetadata annotations helm.sh/hookpost-install,post-upgrade creationTimestamp"2022-01-27T20:21:28Z" generation1 labels app.kubernetes.io/instancetraefik app.kubernetes.io/managed-byHelm app.kubernetes.io/nametraefik helm.sh/charttraefik-10.9.1 nametraefik-dashboard namespacedefault resourceVersion"7217" uid7458ad97-2929-4cc1-94f1-14034d1dd968spec entryPointsweb routeskindRule matchHost(`demo.pf9.io`) && PathPrefix(`/dashboard`) || PathPrefix(`/api`) serviceskindTraefikService nameapi@internalIn our example demo.pf9.io is pointing at the LoadBalancer associated with the ingress controller. Since this is all local we are updating /etc/hosts - however you could also update local DNS to achieve the same results. If our LoadBalancer was a Public IP then we could update DNS for our domain using an A record or CNAME depending on your provider. Realistically you would want to set this up with certificates and TLS, however that is beyond the scope of this getting started guide.
xxxxxxxxxx$ kubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEtraefik LoadBalancer 10.21.75.43 192.168.86.10 80:32111/TCP,443:30796/TCP 5m20sxxxxxxxxxx$ ping demo.pf9.ioPING demo.pf9.io (192.168.86.10)56 data bytes64 bytes from 192.168.86.10icmp_seq=0 ttl=64 time=12.816 ms64 bytes from 192.168.86.10icmp_seq=1 ttl=64 time=12.781 msIf you are having trouble reaching the dashboard on the exposed Ingress route, you can alternatively port-forward the connection via kubectl .
xxxxxxxxxxkubectl port-forward $(kubectl get pods --selector "app.kubernetes.io/name=traefik" --output=name) 9000:9000xxxxxxxxxxForwarding from 127.0.0.1:9000 -> 9000Forwarding from ::1:9000 -> 9000You have now successfully installed Traefik ingress controller for your Kubernetes cluster.