k3s disable Traefik

disable traefik
Views: 46
1 0
Read Time:4 Minute, 41 Second

How to disable Traefik: If you’re well-versed in k3s and its ecosystem, you’re likely aware that the Traefik ingress controller is enabled by default upon installation. However, if you prefer a different ingress controller, these steps will help you disabling Traefik and install your preferred option.

In this article

What is K3s

K3s is a lightweight Kubernetes distribution that is optimized for resource-constrained environments such as edge computing, IoT devices, and development environments. Created by Rancher Labs, K3s aims to provide a simplified, easy-to-install, and lightweight Kubernetes solution while retaining full compatibility with standard Kubernetes APIs and tools.

Here are some key features of K3s:

  1. Lightweight: K3s is designed to have a smaller memory and CPU footprint compared to standard Kubernetes distributions. This makes it suitable for environments with limited resources.
  2. Easy Installation: Installing K3s is straightforward and can be done with a single command. This simplicity makes it ideal for developers and users who want to set up Kubernetes clusters quickly.
  3. Reduced Dependencies: K3s packages all necessary components of Kubernetes into a single binary, reducing the number of dependencies and simplifying the installation process.
  4. Security: Despite its lightweight nature, K3s prioritizes security. It includes features such as integrated containerd runtime, TLS encryption for communication, and support for RBAC (Role-Based Access Control) out of the box.
  5. High Availability: K3s supports high availability configurations for production deployments, allowing for reliable operation even in distributed environments.

Overall, K3s provides a streamlined Kubernetes experience without sacrificing functionality, making it an excellent choice for scenarios where lightweight, easy-to-manage Kubernetes clusters are needed.

For installing k3s just run the following command (from https://k3s.io/ )

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

Traefik is a popular open-source edge router and load balancer that also serves as a feature-rich Kubernetes Ingress Controller. As an Ingress Controller, Traefik manages inbound traffic to your Kubernetes cluster, routing requests to the appropriate services based on rules defined in Kubernetes Ingress resources.

Here are some key features of Traefik as an Ingress Controller:

  1. Dynamic Configuration: Traefik supports dynamic configuration updates, allowing you to modify routing rules, TLS settings, and other configurations in real-time without restarting the service.
  2. Automatic Service Discovery: Traefik can automatically discover new services and endpoints in your Kubernetes cluster, simplifying the configuration process and ensuring that all services are accessible without manual intervention.
  3. Multiple Load Balancing Algorithms: Traefik supports various load balancing algorithms, including round-robin, least connections, and IP hash, allowing you to optimize traffic distribution based on your application’s requirements.
  4. Traffic Splitting and Canary Deployments: With Traefik, you can perform advanced traffic management techniques such as traffic splitting and canary deployments, allowing you to gradually roll out new versions of your applications and test them in production.
  5. Automatic HTTPS: Traefik can automatically generate and manage TLS certificates using Let’s Encrypt or other certificate authorities, enabling secure communication between clients and your services without manual certificate management.
  6. Web-Based Dashboard: Traefik provides a web-based dashboard that allows you to monitor traffic, view routing rules, and perform configuration changes through a user-friendly interface.
  7. Integration with Kubernetes: Traefik is designed to be Kubernetes-native and integrates seamlessly with other Kubernetes components, such as service discovery, ingress resources, and custom resource definitions (CRDs).

Overall, Traefik is a powerful and flexible Ingress Controller for Kubernetes that simplifies the management of inbound traffic, provides advanced traffic management features, and integrates seamlessly with Kubernetes and other infrastructure components. It is widely used in production environments and is known for its ease of use and extensive feature set. Traefik integrates with your existing infrastructure components (Docker,  KubernetesMarathonConsulEtcdRancherAmazon ECS, …) and configures itself automatically and dynamically. Pointing Traefik at your orchestrator should be the only configuration step you need.

Traefik architecture

It seems pretty cool and fully automated but sometime, in the real world, business decision make weird assumption and decide to move away from some products and prefer the adoption of others (sponsorships, internal products, internal testing, etc…)

Remove Traefik

In case you hit one of the above and you have to remove or 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 the one below

[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!

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
Use InfluxDB time series database Previous post Use InfluxDB time series database
PowerShell Tutorial Next post PowerShell Tutorial: Scripting, Automation, and Management
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x