Install Traefik

You can install Traefik with the following flavors:

Use the Official Docker Image

Choose one of the official Docker images and run it with one sample configuration file:

  1. docker run -d -p 8080:8080 -p 80:80 \
  2. -v $PWD/traefik.yml:/etc/traefik/traefik.yml traefik:v2.5

For more details, go to the Docker provider documentation

Tip

  • Prefer a fixed version than the latest that could be an unexpected version. ex: traefik:v2.1.4
  • Docker images are based from the Alpine Linux Official image.
  • Any orchestrator using docker images can fetch the official Traefik docker image.

Use the Helm Chart

Warning

The Traefik Chart from Helm’s default charts repository is still using Traefik v1.7.

Traefik can be installed in Kubernetes using the Helm chart from https://github.com/traefik/traefik-helm-chart.

Ensure that the following requirements are met:

  • Kubernetes 1.14+
  • Helm version 3.x is installed

Add Traefik’s chart repository to Helm:

  1. helm repo add traefik https://helm.traefik.io/traefik

You can update the chart repository by running:

  1. helm repo update

And install it with the helm command line:

  1. helm install traefik traefik/traefik

Helm Features

All Helm features are supported. For instance, installing the chart in a dedicated namespace:

Install in a Dedicated Namespace

  1. kubectl create ns traefik-v2
  2. # Install in the namespace "traefik-v2"
  3. helm install --namespace=traefik-v2 \
  4. traefik traefik/traefik

Installing with Custom Values

You can customize the installation by specifying custom values, as with any helm chart.

The values are not (yet) documented, but are self-explanatory: you can look at the default values.yaml file to explore possibilities.

You can also set Traefik command line flags using additionalArguments. Example of installation with logging set to DEBUG:

Using Helm CLI

  1. helm install --namespace=traefik-v2 \
  2. --set="additionalArguments={--log.level=DEBUG}" \
  3. traefik traefik/traefik

With a custom values file

  1. # File custom-values.yml
  2. ## Install with "helm install --values=./custom-values.yml traefik traefik/traefik
  3. additionalArguments:
  4. - "--log.level=DEBUG"

Exposing the Traefik dashboard

This HelmChart does not expose the Traefik dashboard by default, for security concerns. Thus, there are multiple ways to expose the dashboard. For instance, the dashboard access could be achieved through a port-forward :

  1. kubectl port-forward $(kubectl get pods --selector "app.kubernetes.io/name=traefik" --output=name) 9000:9000

Accessible with the url: http://127.0.0.1:9000/dashboard/

Another way would be to apply your own configuration, for instance, by defining and applying an IngressRoute CRD (kubectl apply -f dashboard.yaml):

  1. # dashboard.yaml
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: IngressRoute
  4. metadata:
  5. name: dashboard
  6. spec:
  7. entryPoints:
  8. - web
  9. routes:
  10. - match: Host(`traefik.localhost`) && (PathPrefix(`/dashboard`) || PathPrefix(`/api`))
  11. kind: Rule
  12. services:
  13. - name: api@internal
  14. kind: TraefikService

Use the Binary Distribution

Grab the latest binary from the releases page.

Check the integrity of the downloaded file

Linux

  1. # Compare this value to the one found in traefik-${traefik_version}_checksums.txt
  2. sha256sum ./traefik_${traefik_version}_linux_${arch}.tar.gz

macOS

  1. # Compare this value to the one found in traefik-${traefik_version}_checksums.txt
  2. shasum -a256 ./traefik_${traefik_version}_darwin_amd64.tar.gz

Windows PowerShell

  1. # Compare this value to the one found in traefik-${traefik_version}_checksums.txt
  2. Get-FileHash ./traefik_${traefik_version}_windows_${arch}.zip -Algorithm SHA256

Extract the downloaded archive

Linux

  1. tar -zxvf traefik_${traefik_version}_linux_${arch}.tar.gz

macOS

  1. tar -zxvf ./traefik_${traefik_version}_darwin_amd64.tar.gz

Windows PowerShell

  1. Expand-Archive traefik_${traefik_version}_windows_${arch}.zip

And run it:

  1. ./traefik --help

Compile your Binary from the Sources

All the details are available in the Contributing Guide