1 min read

K3s reinstall traefik

Redeploy Traefik on the k3s

To configure Traefik create a new YAML file and provide the needed details as shown below.

apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
  name: traefik
  namespace: kube-system
  valuesContent: |-
      - "--api"
      - "--api.dashboard=true"
      - "--api.insecure=true"
      - "--log.level=DEBUG"
        expose: true
        allowCrossNamespace: true

K3s is managing Traefik using CRs: HelmChartConfig and HelmChart. YAML definition above creates HelmChartConfig object on the k3s cluster and k3s will reconfigure the already installed k3s helm charts.

The arguments are passed via additionalArguments - this is modifying the Traefik static parameters. Needed arguments can be added easily.

It's important to say that you need to specify namespace as kube-system, since Traefik should be running there.

When you run kubectl apply -f traefik-custom-conf.yaml, Traefik will be restarted and the new pod will pick up the configuration provided (Can take some time).

If you want to persist the changes on k3s restart you can create a new file in the /var/rancher/k3s/server/manifests/ named traefik-anything-you-want.yaml and k3s will pick up the configuration on file change and k3s restarts.

Be sure to persist already created traefik.yaml and traefik-crd.yaml files in the path mentioned above.