Skip to content

Commands ​

CommandDescription
k3sctl applyInstall or update the cluster
k3sctl resetRemove K3s from the hosts
k3sctl kubeconfigPrint the admin kubeconfig
k3sctl restoreRestore the cluster from an etcd snapshot
k3sctl config diffShow differences between desired config and actual cluster state
k3sctl config validateValidate a cluster configuration file
k3sctl initPrint a configuration template
k3sctl versionPrint version information
k3sctl completionPrint a shell completion script

Global flags ​

FlagDescription
--debugEnable debug logging
--traceEnable trace logging
--no-redactDo not redact sensitive values from output

apply ​

apply reconciles the cluster with the configuration file. It is idempotent: re-running it only changes what drifted.

sh
k3sctl apply --config k3sctl.yaml
FlagDescription
--dry-runShow what would change without changing it
--no-waitDo not wait for the cluster to become ready
--no-drainSkip node draining during the operation
--restore-fromRestore an etcd snapshot before applying
--kubeconfig-outWrite the admin kubeconfig to a file
--kubeconfig-api-addressOverride the API address in the kubeconfig
--kubeconfig-userOverride the user in the kubeconfig
--kubeconfig-clusterOverride the cluster name in the kubeconfig
--concurrencyNumber of hosts to operate on concurrently
--concurrent-uploadsNumber of concurrent file uploads
--disable-downgrade-checkAllow installing an older K3s version
--forceSkip confirmation prompts

restore ​

restore stops K3s, resets etcd state, and restores the cluster from a snapshot. It prompts for confirmation unless --force is given.

sh
k3sctl restore --config k3sctl.yaml --from /path/to/snapshot.db
FlagDescription
--from / -fPath to the etcd snapshot to restore from (required)
--forceSkip the confirmation prompt

config ​

config groups configuration-only commands that do not change the cluster.

diff ​

Preview what apply would change by comparing the desired configuration with the actual cluster state.

sh
k3sctl config diff --config k3sctl.yaml

validate ​

Validate a configuration file without connecting to any host.

sh
k3sctl config validate --config k3sctl.yaml

Common workflows ​

Generate a config ​

Single-node localhost (no SSH):

sh
k3sctl init --localhost --name dev > k3sctl.yaml

Multi-node with a server and an agent:

sh
k3sctl init --name demo --address 10.0.0.1 --agent --agent-address 10.0.0.2 > k3sctl.yaml

When version is left empty in the generated config, k3sctl automatically resolves the latest stable K3s release.

Create a cluster ​

sh
k3sctl apply --config k3sctl.yaml
k3sctl kubeconfig --config k3sctl.yaml > kubeconfig.yaml
export KUBECONFIG="$PWD/kubeconfig.yaml"
kubectl get nodes

k3sctl handles sudo internally — do not prefix commands with sudo.

Validate and preview before applying ​

sh
k3sctl config validate --config k3sctl.yaml
k3sctl config diff --config k3sctl.yaml
k3sctl apply --config k3sctl.yaml --dry-run

Upgrade K3s ​

Edit the version in k3sctl.yaml, then:

sh
k3sctl config diff --config k3sctl.yaml
k3sctl apply --config k3sctl.yaml

k3sctl performs a rolling upgrade with drain/cordon.

Restore etcd ​

sh
k3sctl restore --config k3sctl.yaml --from /path/to/snapshot.db

Snapshots are scheduled with the etcdSnapshots configuration block; see Configuration for scheduling, S3 upload, and pruning.

Tear the cluster down ​

sh
k3sctl reset --config k3sctl.yaml

For step-by-step guides covering single-node, multi-node, and HA topologies, see Quick Start.

version and completion ​

sh
k3sctl version
k3sctl completion bash
k3sctl completion zsh