Where is k3s storing pods? Where is k3s storing pods? kubernetes kubernetes

Where is k3s storing pods?


k3s stands on the shoulders of giants. As container-runtime it uses containerd.And containerd gets configured with its own configuration toml. See man 5 containerd-config:

root : The root directory for containerd metadata. (Default: "/var/lib/containerd")

And this is how /etc/containerd/config.toml looks like:

root = "/var/lib/containerd"state = "/run/containerd"oom_score = 0imports = ["/etc/containerd/runtime_*.toml", "./debug.toml"][grpc]...

The root parameter is the most interesting to you. Here you can find its description:

root will be used to store any type of persistent data for containerd. Snapshots, content, metadata for containers and image, as well as any plugin data will be kept in this location. The root is also namespaced for plugins that containerd loads. Each plugin will have its own directory where it stores data. containerd itself does not actually have any persistent data that it needs to store, its functionality comes from the plugins that are loaded.

/var/lib/containerd/├── io.containerd.content.v1.content   ├── blobs   └── ingest├── io.containerd.metadata.v1.bolt   └── meta.db├── io.containerd.runtime.v1.linux   ├── default   └── example├── io.containerd.snapshotter.v1.btrfs└── io.containerd.snapshotter.v1.overlayfs    ├── metadata.db    └── snapshots


/run should be tmpfs, thus be in ram instead of being on the physical media. The directories reported there are not the actual storage.

Given your goal of storing most things on the usb storage device, the simplest solution would be to move the entire k3s data directory to it, using the --data-dir/-d command line option as per the Documentation. This will force k3s, and the embedded containerd, to place all of their working files and directory on the usb storage.


I believe k3s comes with its own containerd binary and related configuration. By installing k3s explicitly, that is by invoking the "k3s server" command, with the option

--container-runtime-endpoint value         (agent/runtime) Disable embedded containerd and use alternative CRI implementation

you could specify an alternate container runtime that is configured according to your needs, For example with storage in a different volume or partition.

More info in the k3s documentation

Regarding your specific idea though, what happens if the usb stick disappears?