k3s: Unable to disable Traefik

Version: k3s version v1.0.0 (18bd921c)

Describe the bug I am unable to disable the build-in traefik load balancer.

To Reproduce According to documentation all files in /var/lib/rancher/k3s/server/manifests are automatically deployed. I have removed the traefik.yaml file from this folder and changed /etc/systemd/system/k3s.service, followed by systemctl daemon-reload (everything as root user, of course).

The new service file has these lines in it:

ExecStart=/usr/local/bin/k3s \
    server \
    --docker \
    --no-deploy traefik \

Restart k3s service with service k3s stop && service k3s start. (yes, I also tried service k3s restart)

Expected behavior

Expected kubectl -n kube-system get pods to not list traefik pod.

Actual behavior

The pod is still restarted on each service restart.

Additional context

Ubuntu 19.10 with Docker 19.03.2.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 26 (7 by maintainers)

Most upvoted comments

For the record and future me, this is what needs to be done to disable Traefik during initial setup:

  1. Remove traefik helm chart resource: kubectl -n kube-system delete helmcharts.helm.cattle.io traefik
  2. Stop the k3s service: sudo service k3s stop
  3. Edit service file sudo nano /etc/systemd/system/k3s.service and add this line to ExecStart:
    --no-deploy traefik \
  1. Reload the service file: sudo systemctl daemon-reload
  2. Remove the manifest file from auto-deploy folder: sudo rm /var/lib/rancher/k3s/server/manifests/traefik.yaml
  3. Start the k3s service: sudo service k3s start

Just updating to mention that --no-deploy is deprecated, and now people referring to this should use --disable instead.

@riker09 you can still use the no-deploy with the install script, you just need to run the command as follows:

curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --no-deploy traefik" sh

This will configure the server with no traefik and you wont find it in the manifests

thats also described here in the docs https://rancher.com/docs/k3s/latest/en/installation/install-options/#installation-script-options

Disable traefik post installation:

helm -n kube-system delete traefik traefik-crd
kubectl -n kube-system delete helmchart traefik traefik-crd
touch /var/lib/rancher/k3s/server/manifests/traefik.yaml.skip
systemctl restart k3s

This should be a better approach, except for cleaning up the traefik part, which is in fact the main reason I’m here. We no longer need to use parameters or environment variables to modify systemd service files. And have good compatibility with upgrades, I think. If you want to re-enable traefik, just delete traefik.yaml.skip and restart k3s. About the .skipfiles: https://rancher.com/docs/k3s/latest/en/installation/disable-flags/

curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --disable traefik" sh

@cawoodm Maybe you missed the = between disable and traefik

curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik" INSTALL_K3S_VERSION="1.23.3" sh -

This still seems to be an issue. Following the instructions @Cesarsk and @himao posted seems to clean up everything but the traefik service. I run kubectl delete svc traefik -n kube-system and it says it is deleted but the command never returns back to the prompt. It also is still in the get request.

no, now you’ve got a pipe with no command. You want both of the variables after the pipe

curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="server --disable=traefik" sh -