Declarative K3s clusters with k3sctl
k3sctl manages the lifecycle of a K3s cluster from a single configuration file. It was created and inspired by k0sctl: you describe the hosts you want, and the tool does the work over SSH.
The file is the desired state
A k3sctl configuration is a Cluster document with an apiVersion of k3sctl.k3sproject.io/v1beta1. Each entry in spec.hosts has a role of server or agent, so the same file describes both the control plane and the workers.
Because the file is the desired state, the normal workflow is to edit it and run apply again. apply is idempotent: it only changes what drifted, and --dry-run shows the plan without touching the cluster.
What it handles
- Installing and upgrading K3s binaries from GitHub releases, a URL, a local file, or an existing installation on the host.
- Generating server and agent configuration plus systemd units.
- Labels, taints, extra install flags, environment variables, and arbitrary file uploads.
- Applying additional Kubernetes manifests bundled in the same file.
- etcd snapshots with
backup, member validation, and restore. - Fetching a ready-to-use admin kubeconfig with
kubeconfig.
Because the binary drives the hosts directly, servers and agents must be Linux and reachable over SSH with root or passwordless sudo.
Getting started
k3sctl init --name demo --address 10.0.0.1 --agent --agent-address 10.0.0.2 > k3sctl.yaml
$EDITOR k3sctl.yaml
k3sctl apply --config k3sctl.yaml
k3sctl kubeconfig > kubeconfig.yamlRead the installation guide for release binaries and source builds, or the configuration reference for every host and K3s option. k3sctl is Apache-2.0 licensed.