krabkube 0.2.0

Lightweight kubelet and Kubernetes-compatible runtime for 1 GB machines (krab binary)
krabkube-0.2.0 is not a library.

krabkube

A 5 MiB kubelet for a real Kubernetes cluster. krab agent is a single static Rust binary that turns a 1 GB machine into a worker node of k3s or kubeadm (Kubernetes 1.30 to 1.34): it registers the node, runs pods, serves kubectl logs/exec/port-forward/top, routes ClusterIP and DNS, and joins the cluster with a normal bootstrap token. Instead of kubelet + kube-proxy + CNI + containerd (about 90 to 120 MiB on k3s) the worker side is 5 to 8 MiB of RAM.

Status: beta. It works against real clusters in CI, but it is not a certified Kubernetes distribution and has not been through the CNCF conformance suite. Read Limitations before putting it anywhere important.

# on the worker (1 GB VM), after `kubeadm token create --print-join-command` on the cluster
sudo KRAB_VERSION=v0.2.0 sh deploy/install.sh
sudoedit /etc/krab/agent.env        # server, ca hash, node name
sudo sh -c 'umask 077; cat > /etc/krab/join-token'
sudo systemctl enable --now krab-agent
kubectl get nodes -o wide           # runtime: krab-native://

Full guide: docs/AGENT.md. Decision record: ADR 0008.

Numbers

RSS of the agent process (VmRSS, median of 3 runs unless noted), without youki and the containers themselves:

krab agent k3s worker side (kubelet, kube-proxy, flannel, containerd)
idle 4.8 to 6 MiB 86.6 MiB
20 pods 6.5 to 8 MiB 121.4 MiB
~24 pods at once, full sig-node check run 10.2 MiB not measured
binary (static musl) about 6 MiB k3s 200 MiB
  • The budget is 10 MiB idle and 15 MiB with 20 pods (ADR 0008). Every step was measured and recorded in bench/RESULTS.md.
  • Not comparable one to one: the k3s figure includes containerd and kube-proxy, the krab figure excludes the per-container youki shim (about 5 MiB per running container) and the container processes. A 2-hour soak with pod churn is run with SOAK=7200 bench/agent-k3s.sh.
  • Same numbers on arm64 (4.9 idle, 6.5 with 20 pods), on a real 1 GB Oracle VM with the native runtime (5.1 idle, 6.8 with 20 pods).
  • How k3s was measured: docs/research/h-worker-baseline.md.

What works

  • Join: krab agent join with a bootstrap token and --ca-hash, discovery via cluster-info, CSR for the node client certificate, rotation at 80% of its lifetime.
  • Node: registration, Lease, honest Memory/Disk/PID pressure conditions, eviction of BestEffort then Burstable pods under memory pressure, unused image garbage collection.
  • Pods: init containers, restart policies and back-off, liveness/readiness/startup probes (exec, httpGet, tcpSocket), postStart/preStop hooks, activeDeadlineSeconds, env (fieldRef, resourceFieldRef, ConfigMap, Secret), volumes (emptyDir, hostPath with an allow list, ConfigMap, Secret, projected, downwardAPI, local-path PVC) with live ConfigMap/Secret updates, terminationMessagePath, projected ServiceAccount tokens refreshed before expiry.
  • Kubelet API on 10250 with client-certificate or token authentication and SubjectAccessReview authorization: logs, exec, attach, port-forward, /metrics/resource (so kubectl top works with a real metrics-server), /stats/summary.
  • Network (native runtime): pod CIDR from Node.spec, WireGuard between krab nodes, ClusterIP through nftables, cluster DNS.
  • Containers run through youki with a seccomp default profile, no privileged pods, no host network.

Compatibility

Control plane Result
k3s 1.34.1 agent suite, join with rotation, kubectl top, two-node networking: pass (CI job k3s, k3s-join-top)
kubeadm 1.30, 1.31, 1.32, 1.33, 1.34 with a containerd node next to a krab node join, Deployment spread over both nodes, logs, exec (CI job kubeadm; 1.31 and 1.32 are new in the matrix)

bench/node-checks.sh is a fast subset of the sig-node behaviour (35 checks: restarts, env, volumes, probes, hooks, lifecycle, signals). On kubeadm 1.34 it passes 34 of 35; the one failure is the OOMKilled reason. The official [Conformance] suite is not run: each failing spec waits minutes. Details and what was fixed: docs/research/i-node-conformance.md.

Limitations

  • Linux only (cgroup v2, root), IPv4 only. Worker role only: no control plane in krab agent.
  • No CSI and no cloud volume plugins, no NetworkPolicy, no hostNetwork or privileged pods, no custom seccomp profiles per pod, no subPath on emptyDir.
  • The kubelet-serving CSR needs an admin approval, as with kubelet serverTLSBootstrap; until then logs/exec/top do not work (pods still run).
  • Eviction and image garbage collection are covered by unit tests, not yet by a live load test.
  • WebSocket exec through the apiserver is not verified; kubectl exec over SPDY works.
  • HA control planes, kubeadm 1.31/1.32 locally, ARM with the native runtime are not tested. Windows and macOS workers are not supported (ADR 0010).
  • Not audited by a third party. An internal security review is in docs/SECURITY-REVIEW.md.

Standalone mode (experimental)

The same binary can also serve its own small Kubernetes-compatible API (krab serve) for a single machine, with the control plane at about 4 MiB. It predates the agent and is described below.

Why

k3s and k0s need most of a gigabyte before they run a single pod. On an always-free 1 GB cloud VM that leaves nothing for your own workloads. krab implements the part of Kubernetes people actually use on a single small box (API server, store, scheduler, kubelet, Deployment/ReplicaSet/Endpoints controllers) in one process with a strict memory budget.

Numbers

memory chart

krab k3s
idle control plane 4.3 MiB 387 MiB (anon), 509 MiB with page cache
20 pods running 5.7 MiB not measured
peak under 1000 list requests with a watch open 8.0 MiB not measured
binary (static musl, x86_64) 4.28 MiB not measured

How it was measured, and what is not comparable, is in bench/RESULTS.md. Short version: krab figures are VmRSS/VmHWM of the krab process on the same host as k3s, three runs; krab drives the Docker daemon, whose memory is not included, while the k3s figure includes its embedded containerd.

Compatibility

tests/compat/run.sh runs 45 real kubectl 1.33.4 scenarios against any cluster: create/apply/idempotent apply, ConfigMap/Secret/env/volumes, Deployment rollout, scale, three patch types, server-side apply, rollout history/undo/restart, exec, logs, events, top, watch, selectors, Service DNS, cascade delete, namespace delete.

Cluster Result
k3s 1.34.1 44 / 45 (top pods needs metrics-server, disabled in that run)
krab 45 / 45

tests/e2e/exec_pf.sh covers exec (stdout, stderr, exit code, stdin, large output), logs and port-forward over SPDY: 10 / 10.

This is not the CNCF conformance suite. It has not been run, and krab is not a certified Kubernetes distribution. See docs/research/f-conformance.md for what certification would take.

What works

  • API: discovery (legacy and aggregated v2), Table printing, watch with bookmarks and 410 Gone, list pagination, JSON/merge/strategic-merge patch, server-side apply (simplified), dry-run, metrics.k8s.io, /metrics
  • Resources: Namespace, Node, Pod, Service, Endpoints, ConfigMap, Secret, ServiceAccount, Event, Lease, Deployment, ReplicaSet (with scale and status subresources)
  • Controllers: scheduler, kubelet (probes, init containers, env from ConfigMap/Secret/fieldRef, volumes), ReplicaSet, Deployment (RollingUpdate, Recreate, history), Endpoints, node lease, ownerReference garbage collection
  • Security basics: privileged pods, hostNetwork and hostPath outside --allow-host-path are rejected, TLS by default (generated CA, server and admin certificates), client-certificate and static-token authentication, constant-time token comparison, kubeconfig generation, exec restricted to containers krab itself created
  • Persistence: embedded redb store that survives kill -9 (30 consecutive crash tests, see docs/research/c2-store-bench.md)
  • Foreign containers already running on the host show up as read-only pods; krab never stops or changes them

Limitations

Be aware before you rely on it:

  • Containers are run through the Docker API. A containerd/CRI backend is planned. There is no Docker on the Oracle 1 GB VM this project targets, so that machine needs the next backend.
  • No ClusterIP routing. Services get an IP and Endpoints, and pods reach each other by name through Docker network aliases (web, web.ns.svc.cluster.local). NodePort and Ingress are not implemented.
  • No RBAC enforcement: every authenticated user is an administrator. Secrets are stored unencrypted unless --encryption-key-file is set (see Security).
  • One node. No HA, no multi-node join yet.
  • No OpenAPI schemas (kubectl explain shows nothing), no CRDs, no admission webhooks, no PersistentVolumes.
  • kubectl create deployment and a few other typed commands send protobuf bodies for types krab does not decode; use kubectl apply -f for those.
  • Lens and Helm are not verified. k9s connects, passes its access checks and opens the pods view; the table rendering was not confirmed automatically.
  • Tested on Linux x86_64 only. Not run on ARM.

An independent security review (34 findings) is in docs/SECURITY-REVIEW.md with the status of each. All critical and high findings are fixed; a few medium ones are deferred and listed there. There is no RBAC yet, so do not expose krab to untrusted networks.

Security

Secrets can be encrypted at rest with AES-256-GCM:

krab keygen --out /etc/krab/secrets.key
krab serve --encryption-key-file /etc/krab/secrets.key ...
  • Only Secret objects are encrypted, in memory and in store.redb; ConfigMaps, Events and other objects are not. Clients and watches always get plaintext.
  • On start with a key, existing plaintext Secrets are re-encrypted in place. To rotate, put a new key on the first line of the file (old keys stay below for reading) and run krab rekey --data-dir DIR --encryption-key-file FILE while the server is stopped.
  • The key file must be mode 0600 or stricter and should live outside the data directory and its backups. Losing it makes the Secrets unreadable (the API answers 500).
  • Limitations: the key sits on the same disk as the process (no KMS), nonces are random 96-bit values, there is no command to decrypt back to plaintext, and pages of store.redb freed by migration may still hold old plaintext until redb reuses them.

Quick start

Requirements: Linux with Docker, kubectl.

Build a static binary (see docs/DEV.md for the musl recipe) or cargo build --release, then:

krab serve --listen 127.0.0.1:6443 --data-dir ~/.krab &
krab kubeconfig --server https://127.0.0.1:6443 --data-dir ~/.krab --out ~/.krab/kubeconfig
export KUBECONFIG=~/.krab/kubeconfig
kubectl get nodes
kubectl apply -f your-manifests.yaml

Useful flags: --insecure-http (local testing only), --token, --no-controllers (read-only facade over Docker), --store-sync eventual, --poll-secs. hostPath volumes, privileged containers, host namespaces and added capabilities are rejected with 403; --allow-host-path DIR (repeatable) permits hostPath volumes inside DIR.

How it fits together

flowchart LR
  kubectl[kubectl / k9s / Prometheus] -->|HTTPS| api[krab-api]
  api --> store[(krab-store: memory + redb)]
  ctl[krab-controllers: scheduler, kubelet, controllers] <--> store
  ctl --> rt[krab-runtime]
  rt --> docker[Docker API]
  api -. exec / port-forward .-> rt

Everything runs in one process on a single-threaded tokio runtime. Objects are stored and served as raw JSON; only metadata and the few fields the controllers need are parsed. Details: docs/ARCHITECTURE.md, decisions in docs/adr, research behind them in docs/research, plan in docs/ROADMAP.md.

Development

cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace

Stand, build and measurement instructions: docs/DEV.md. Project history and open items: docs/PROGRESS.md. How the agent team works on this repository: AGENTS.md.

License

MIT, see LICENSE.