krabkube 0.1.0

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

krabkube

A Kubernetes-compatible runtime for small machines. One static Rust binary, krab, that speaks the Kubernetes API, so kubectl, k9s, Helm-style manifests and Prometheus scraping work against it, while the control plane itself stays around 4 MiB of RAM.

krab demo

The recording is a real session on a Linux host: krab serve, kubectl apply of a Deployment and a Service, rollout, exec, port-forward, scale, rolling update, top, and the RSS of the krab process at the end.

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 in the data directory.
  • 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 and no secret encryption yet, so do not expose krab to untrusted networks.

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.