Reducing Kubernetes Overhead: Using SQLite with K3s for Edge Deployments
Learn how K3s uses SQLite and the Kine shim to replace etcd, reducing memory overhead for edge and single-node Kubernetes deployments.
09 Aug 2025, 10:20 UTC

The Resource Tax of etcd
Standard Kubernetes distributions rely on etcd, a distributed key-value store that ensures consistency across a cluster. While powerful, etcd is resource-intensive. It requires significant RAM and fast disk I/O to maintain its consensus algorithm (Raft). For engineers deploying to edge devices, ARM64 gateways, or single-node development environments, the overhead of etcd often consumes more resources than the actual applications being hosted.
The practical takeaway is that K3s solves this by using SQLite as the default datastore for single-node installations. By swapping a distributed database for a local file-based one, K3s drastically lowers the memory floor required to run a functional Kubernetes API.
How Kine Bridges the Gap
Kubernetes is hard-coded to expect an etcd-compatible API. To use SQLite without rewriting the core Kubernetes codebase, K3s employs a shim called Kine (Kubernetes In Cluster NEtwork Engine).
Kine acts as a translation layer. When the Kubernetes API server sends a request to store a pod specification or a configmap, Kine intercepts that request and translates the etcd-style call into a SQL query that SQLite understands. This allows the cluster to function normally while the actual state is stored in a simple .db file on the local disk.
Deployment and Verification
In a standard K3s installation, SQLite is enabled by default if no external database is specified. To verify that your node is utilizing the SQLite backend rather than an external provider, you can inspect the server's data directory.
Run the following command on the server node (requires root or sudo permissions):
ls -lh /var/lib/rancher/k3s/server/db/
Expected Result: You should see a k3s.db file. This file contains the entire state of your cluster. If this directory is empty or contains different structures, the cluster may be configured for High Availability (HA) using an external database like PostgreSQL or MySQL.
Diagnostic Check: Memory Footprint
To see the impact of this lightweight architecture, you can compare the memory usage of the K3s process against a standard kubeadm installation. On a K3s node, run:
kubectl top nodes
While kubectl top shows overall node usage, checking the process list via top or htop will reveal that the combined K3s binary (which bundles the API server, scheduler, and Kine) typically consumes significantly less RAM than the separate etcd and kube-apiserver processes found in standard distributions.
Trade-offs: SQLite vs. etcd
Choosing SQLite is a conscious decision to trade availability for efficiency. Because SQLite is a local file, it cannot be shared across multiple server nodes to provide a quorum. This introduces specific limitations:
- No Native HA: If the node hosting the SQLite database fails, the cluster state is lost unless the disk is backed up or attached to a shared network volume.
- Write Contention: SQLite uses database-level locking. In environments with extremely high churn (thousands of object updates per minute), you may encounter locking delays that would not occur in a distributed etcd cluster.
- Disk I/O: While lighter than etcd, SQLite still relies on disk syncs. Using a slow SD card on an edge device can still create bottlenecks during heavy API activity.
Moving Toward High Availability
If your project outgrows a single-node SQLite setup, you do not need to migrate to a full-blown etcd cluster immediately. K3s allows you to switch the backend to an external SQL database (PostgreSQL or MySQL) via the --datastore-endpoint flag. This provides a middle ground: the reliability of a managed database without the operational complexity of managing an etcd quorum manually.
Verification Step: Before moving to production, always verify your backup strategy for the /var/lib/rancher/k3s/server/db/ directory. Since the entire cluster state lives in that single file, a simple file-level backup is often sufficient for disaster recovery in edge scenarios.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.