K3s

Installation

  • Disable swap memory

    • comment swap.img in /etc/fstab

    • swapoff -a

  • sudo curl -sfL https://get.k3s.io | sh -

    • By default: service cidr: 10.43.0.0/16 and pod cidr: 10.42.0.0/16

    • to change it, add --cluster-cidr=10.0.0.0/16 --service-cidr=10.1.0.0/16 to above command

  • Join Master Node from agent node:

    • sudo cat /var/lib/rancher/k3s/server/node-token on your server: get NODE_TOKEN from master node

    • sudo k3s agent --server https://myserver:6443 --token ${NODE_TOKEN}

  • Installing and registering at the same time, all below commands have the same result

curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="agent --server https://k3s.example.com --token mypassword" sh -s -
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="agent" K3S_TOKEN="mypassword" sh -s - --server https://k3s.example.com
curl -sfL https://get.k3s.io | K3S_URL=https://k3s.example.com sh -s - agent --token mypassword
curl -sfL https://get.k3s.io | K3S_URL=https://k3s.example.com K3S_TOKEN=mypassword sh -s - # agent is assumed because of K3S_URL

Verification

  • systemctl status k3s.service

  • systemctl status k3s-agent.service

Uninstallation

  • Master Node: /usr/local/bin/k3s-uninstall.sh

  • Agent: /usr/local/bin/k3s-agent-uninstall.sh

Ingress-Controller

  • K3s uses Traefik as the default Ingress controller

  • Traefik Handles Ingress traffic using ports 80 and 443.

  • Uses ServiceLB to distribute traffic across nodes.

  • Can be customized via HelmChartConfig (/var/lib/rancher/k3s/server/manifests/traefik.yaml).

  • To disable traefik, start K3s with --disable=traefik

Troulbeshooting

Service is activiting

  • Solution: ensure minimum server requirement is met

Reference

Last updated