Disable Traefik from K3s
If you are familiar with k3s and the world it belongs you might know that by default, when you install k3s the Traefik ingress controller is being enabled. If you already went through the steps of installing k3s the following steps will allow you to disable Traefik and let you install the ingress controller you like most.
In this article
What is K3s
k3s is a lightweight kubernetes distribution created by Rancher Labs and is CNCF certified (Cloud Native Computing Foundation). It has a very small binary size and low resource consumption. Main difference between k8s and k3s is that k8s is a general purpose container orchestrator and k3s is a purpose built container orchestrator for running kubernetes on physical devices.
For installing k3s just run the following command (from https://k3s.io/ and a small hack 😀 if this is on a Raspberry PI you can have a look a this https://keepforyourself.com/kubernetes/install-k3s-on-a-raspberry-pi/)
If you instead want to deeply dive into k3s and rancher word these two books are a MUST to have
Edge Computing and K3s | Rancher World! |
---|---|
curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
# Check for Ready node,
takes maybe 30 seconds
k3s kubectl get node
What is Traefik
From https://github.com/traefik/traefik Traefik (pronounced traffic) is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. Traefik integrates with your existing infrastructure components (Docker, Swarm mode, Kubernetes, Marathon, Consul, Etcd, Rancher, Amazon ECS, …) and configures itself automatically and dynamically. Pointing Traefik at your orchestrator should be the only configuration step you need.
It seems pretty cool and fully automated but sometime, in the real world, business decision make weird assumption and drive these adoption (sponsorships, internal products adoption, internal testing, was already working like that, how much effort for change, estimations etc…)
How to disable Traefik
In case you hit one of the above and you have to disable traefik, you can follow these steps:
- Remove Traefik helm chart by executing this kubectl command:
kubectl -n kube-system delete helmcharts.helm.cattle.io traefik
- Stop k3s:
sudo service k3s stop
- Edit the k3s service file
/etc/systemd/system/k3s.service
by adding this line to the ExecStart- –no-deploy traefik \
The k3s service file should look like
[Unit]
Description=Lightweight Kubernetes
Documentation=https://k3s.io
Wants=network-online.target
After=network-online.target
[Install]
WantedBy=multi-user.target
[Service]
Type=notify
EnvironmentFile=-/etc/default/%N
EnvironmentFile=-/etc/sysconfig/%N
EnvironmentFile=-/etc/systemd/system/k3s.service.env
KillMode=process
Delegate=yes
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=1048576
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
TimeoutStartSec=0
Restart=always
RestartSec=5s
ExecStartPre=/bin/sh -xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service'
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s \
server \
--no-deploy traefik \
After that reload the service and remove the auto-deploy traefik manifest
sudo systemctl daemon-reload
sudo rm /var/lib/rancher/k3s/server/manifests/traefik.yaml
Then restart the k3s service
sudo service k3s start
Job done!
I hope it helps you in some way or another. Please share and let us grow!
You might also find this article useful
AND
if you really want….feel free to pay us a coffee Buy us a coffee