k3s
Configuration Commands
Customize k3s using config files, environment variables, and command-line flags.
12 commands
Pro Tips
Use /etc/rancher/k3s/config.yaml for persistent settings
Commands
Create config file
$ sudo mkdir -p /etc/rancher/k3s && sudo touch /etc/rancher/k3s/config.yaml
Create k3s configuration file.
View k3s check-config
$ k3s check-config
Check system requirements.
Enable secrets encryption
$ curl -sfL https://get.k3s.io | sh -s - --secrets-encryption
Install with secrets encryption enabled.
Configure private registry
$ sudo nano /etc/rancher/k3s/registries.yaml
Edit registries.yaml to configure private container registries.
Disable multiple components
$ curl -sfL https://get.k3s.io | sh -s - --disable traefik --disable servicelb --disable metrics-server
Install k3s with multiple built-in components disabled.
Set custom data directory
$ curl -sfL https://get.k3s.io | sh -s - --data-dir /opt/k3s
Store k3s data in a custom directory instead of /var/lib/rancher/k3s.
Configure containerd
$ sudo cp /var/lib/rancher/k3s/agent/etc/containerd/config.toml /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl
Create custom containerd config template for k3s.
Set node name
$ curl -sfL https://get.k3s.io | sh -s - --node-name my-node
Install with a custom node name instead of hostname.
Set cluster CIDR
$ curl -sfL https://get.k3s.io | sh -s - --cluster-cidr 10.42.0.0/16 --service-cidr 10.43.0.0/16
Configure custom pod and service CIDR ranges.
Use flannel backend
$ curl -sfL https://get.k3s.io | sh -s - --flannel-backend wireguard-native
Install with WireGuard-native as the flannel backend for encrypted networking.
Set kubelet args
$ curl -sfL https://get.k3s.io | sh -s - --kubelet-arg max-pods=150
Pass custom arguments to the kubelet process.
Disable cloud controller
$ curl -sfL https://get.k3s.io | sh -s - --disable-cloud-controller
Disable the built-in cloud controller manager.