Linux

Where Does K3s Store Data and Kubeconfig?

K3s server data under /var/lib/rancher, agent state, and the kubeconfig it writes.

Last updated

K3s roots server state in /var/lib/rancher/k3s: the embedded datastore, deployed manifests, agent state and containerd content together. Agent nodes keep a slimmer copy of the same tree for their local workloads. Everything hangs off the rancher path, which makes full node backup a single directory copy.

The kubeconfig takes a separate fixed path. K3s writes admin credentials to /etc/rancher/k3s/k3s.yaml on first boot, independent of the data tree. That split means cluster access and cluster data back up through different files, and losing track of either one strands you differently.

Where K3s stores this, by platform

Linux
/var/lib/rancher/k3s

Requires root to browse. Key children include server for datastore and manifests, agent for node state, and data for binaries. Copy with K3s stopped. The kubeconfig at /etc/rancher/k3s/k3s.yaml needs its own backup step.

Frequently asked questions

how do i back up a k3s server

Back up /var/lib/rancher/k3s/server with K3s stopped, covering the embedded etcd or sqlite state plus manifests. Agent only nodes need no backup beyond their config, since workloads reschedule from the server state.

where is the k3s kubeconfig file

Read /etc/rancher/k3s/k3s.yaml on the server node. K3s writes admin credentials there on first start, and copying it to ~/.kube/config gives kubectl access. Protect the file like a password, since it grants full cluster control.

Notice an outdated path? Let us know.