Skip to main content

Disable bundled Traefik in K3S

·1 min·
Kubernetes Homelab Rpi Gist
Massimiliano Donini
Author
Massimiliano Donini
🚀 Freelance Cloud Architect | Based in The Netherlands 🇳🇱 | Ready to collaborate on cutting-edge Azure & .NET projects! 💡 Let’s talk Azure, .NET, EF Core, ASP.NET Core, Terraform, GitHub, and CI/CD automation. Got a question or an exciting project? Let’s connect! 🔥

While automating the installtion of my K3S cluster with ansible, I struggled to disable traefik (and I’m not the only one, see this), the issue what that the file /etc/systemd/system/k3s.service was looking like this:

ExecStart=/usr/local/bin/k3s \
    server \
        '--write-kubeconfig-mode' \
        ' 0644' \
        '--node-taint' \
        'node-role.kubernetes.io/control-plane:NoSchedule' \
        ' --disable' \
        'traefik' \
        ' --disable' \
        'servicelb' \
        ' --disable' \
        'local-storage' \
        ' --kubelet-arg' \
        'config=/etc/rancher/k3s/kubelet.config' \
        ' --kube-controller-manager-arg' \
        'bind-address=0.0.0.0' \
        ' --kube-proxy-arg' \
        'metrics-bind-address=0.0.0.0' \
        ' --kube-scheduler-arg' \
        'bind-address=0.0.0.0' \
        ' --kube-controller-manager-arg' \
        'terminated-pod-gc-threshold=10' \

This version still ends up installing Traefik v2, bundled with K3S. The correct k3s.service file look like the following:

ExecStart=/usr/local/bin/k3s \
    server \
        '--write-kubeconfig-mode' \
        '0644' \
        '--node-taint' \
        'node-role.kubernetes.io/control-plane:NoSchedule' \
        '--disable' \
        'traefik' \
        '--disable' \
        'servicelb' \
        '--disable' \
        'local-storage' \
        '--kubelet-arg' \
        'config=/etc/rancher/k3s/kubelet.config' \
        '--kube-controller-manager-arg' \
        'bind-address=0.0.0.0' \
        '--kube-proxy-arg' \
        'metrics-bind-address=0.0.0.0' \
        '--kube-scheduler-arg' \
        'bind-address=0.0.0.0' \
        '--kube-controller-manager-arg' \
        'terminated-pod-gc-threshold=10' \

The fix was to configure yaml to account for end of line properly, check this to dig deeper into yaml multiline options.