kith Guide GitHub

kith (n.) one's close circle; the people you trust.

All of your machines, one cluster.

kith is a tiny, immutable operating system and one small daemon. It joins your machines into a cluster and keeps them matching the YAML you apply: containers, virtual machines, storage, DNS, and the network between them.

Run it on one machine Read the guide

Version 1.0.0. No release is tagged yet: it is built from source.

desktop laptop server the old PC
$ kith apply -f hello.yamlhello: 7 of 7 replicas ready, on 4 machinesShown faster than life: a lost machine's replicas start elsewhere only after --lost-after, five minutes unless you say otherwise.
12MB

kithd: the store, the scheduler and the runtime in one static binary

4.71MB

of memory held by kithd with nothing to do, its binary read from disk

32.1MB

a whole kith OS update: kernel, root and its hash tree

38

built-in kinds of resource, all in one strict schema

01 Apply

Say what should run. Apply it.

Every resource is the same shape of YAML. kith lint checks files with no daemon, kith diff says what would change, and kith apply is all or nothing. Each change is a revision, and kith rollback goes back to one. What you wrote for Kubernetes works as it is: kithd answers kubectl and helm for Deployments, StatefulSets, Jobs, Services and the rest of the core kinds, and nothing of Kubernetes runs behind it.

hello.yaml
apiVersion: kith.dev/v1
kind: Workload
metadata:
  name: hello
spec:
  template:
    containers:
      - name: main
        image: mirror.gcr.io/library/busybox:1.36
        command:
          - sh
          - -c
          - while true; do echo hello; sleep 5; done
        resources:
          memory: 32Mi
          cpu: 100m
a terminal
$ kith apply -f hello.yaml
Workload/default/hello created (revision 1)
$ kith get
KIND      NAMESPACE  NAME   REVISION  STATUS
Workload  default    hello  1         1/1 ready
$ kith lint -f web.yaml
web.yaml:7:13: invalid type: string "yes", expected u32
  |   replicas: yes
  |             ^

02 Cluster

Three machines, and one can go.

One command on the first machine, a token, one command on each of the others. There is no separate control plane to install: every node is the same kithd.

Pulse 3 of 3 nodes up, 3 of 3 replicas ready
alpha beta gamma
  • webon alpha, beta and gamma
  • leadergamma
  • Every node keeps the whole store. A change is on the disks of more than half of the voting nodes before it is answered.
  • Lose the leader and the other two pick a new one within a few seconds.
  • The nodes find each other over a WireGuard mesh that kithd sets up itself: directly where they can, through an edge node where they cannot.
  • Tested by breaking it. The chaos test cuts off and resets every node in turn, then all three at once. Every write that was acknowledged is on all three afterwards.
  • Shown faster than life: a silent node reads unreachable after ten seconds, and its replicas still count as ready until it has been gone for --lost-after (five minutes unless you say otherwise); then they start elsewhere.

03 kith OS

An operating system with nothing to log into.

kithd is the machine's first process. The root is 6.2 MB, read-only, and checked block by block as it is read. There is no shell, no libc and no package manager. A node runs from one slot and updates into the other, so the system that runs is never the one being changed.

A node's disk running slot a
espboot loader, kernels
root-aread-only, verified
root-bthe other slot
statethe only partition a node writes
  1. Written and checked. Each piece of a signed update is held to the SHA-256 in its header as it lands in the other slot.
  2. Three tries. The node restarts into the new slot, and the boot loader counts each start.
  3. Good after ten seconds. A slot whose kithd is still running then is kept.
  4. Otherwise, back. When the tries are gone the slot that worked starts again, and says so.

Updates are signed, and a node takes none older than the newest it has run well. A release can hand its keys over to new ones. An UpdatePlan rolls a release through the cluster, one node at a time unless you say more.

kith OS from a spec one build for the machines that need it
  1. A spec. features: [gpu-amd-phoenix]: a feature is named, with no file names and no versions.
  2. Compiled in. os/build.sh --spec builds its kernel config and the firmware its driver loads into the kernel.
  3. A selector. Each image is signed as its own OSRelease, and an UpdatePlan with a selector rolls it to the nodes that carry a label.
  4. Rolled out. Those nodes update into their other slot, as above.

04 Hardware

A GPU to share. A seat for a desktop.

Hardware is a resource like the rest: a Device a workload claims, and a Seat that holds a screen, a keyboard and a GPU together. What a workload may take is written in its YAML, and a claim that does not fit waits and says why.

Shares of a GPU's memory an example, 8 GiB

render

4 GiB

encode

2 GiB

notebook

1 GiB

batch

2 GiB, 1 left

Each claim says share: { vram: 512Mi } or more. Shares add up, and the one that does not fit waits: its message gives the numbers.

  • A share is a ceiling where the driver gives the kernel's dmem cgroup a region (amdgpu, xe, NVIDIA's). Each container gets the sum of its shares as dmem.max, and the claim's status says enforced: true.
  • Where kithd cannot hand the controller down (it is not root) there is no ceiling, and the status says enforced: false. A share is then a promise between workloads.
  • A seat is given to a namespace by a label. A session that claims it takes its screen, keyboard and GPU, and no other workload can.

A desktop is a package.

kith has no desktop of its own: a node nobody gives one stays headless. A package renders a session that holds a seat, and deleting the release makes the node headless again. kith ships no desktop images: you name one you built or trust.

On a seat

A screen on the machine

gnomehyprlandkioskkith-panel

In a browser

No screen needed

selkies

a desktop on a seat
$ kith package render packages/hyprland \
    --name office -n desktop \
    --set seat=SEAT --set image=IMAGE \
  | kith apply -f -

Selkies is a desktop in a browser: a pod behind a Service on port 8080, and its login is the password of a Secret you make first. On a spare kith OS PC it answered 401 without the password, and 200 with it.

05 Build

Test on the cluster you are building.

The tests of a pushed commit can run on another kith node, as a Job there, in a pod, as a user that is not root. ci/remote.sh prints what failed and how long it took, and exits as cargo test did.

from your machine
$ KITH_REMOTE=ADDR \
  KITH_REMOTE_CREDS=DIR \
  sh ci/remote.sh
  1. your commit
  2. a Job on a node
  3. cargo test, in a pod
  4. what failed, and the time
On a kith OS mini PC with 16 CPUs

218s

every test

The whole workspace, from a fresh clone. One test, node_policy_refuses_what_the_node_turned_off, timed out in the pod: it differs there.

06 Numbers

Small, and held to it.

Four budgets are measured by ci/budgets.py, and a build that goes over one fails. Every figure on this page is measured the same way and written here by a script: none is typed in.

kith, the command

2.92 MB of 3

kithd, everything else

12 MB of 13

kithd idle, memory

4.71 MB of 9

kith apply, peak memory

2.71 MB of 4

Static binaries for x86-64. The line at the right of each bar is its budget.

1071

tests in the tree

23

more that boot whole machines in QEMU

114407

lines of Rust, with unsafe forbidden outside one small crate

14

crates in one workspace

07 Kinds

38 kinds, one way to say them.

What runs, where its data lives, who may change it, and the machines themselves are all resources. You can define kinds of your own, with controllers and admission in WebAssembly. They are written in YAML, or in kith's own small language: a .kith file has names, functions and imports, gives the same resources, and is checked against the same schemas. Every node serves a web page with a form for each of them, drawn from its schema.

Run

Containers, plain processes and virtual machines

WorkloadNodeWorkloadJobCronJob

Reach

Names, load balancing, ingress with ACME, a DNS server

ServiceDNSZoneDNSRecordDNSBlockListNetworkPolicy

Tunnels

A WireGuard way out for pods, and what a person's device reaches

ExitAccessLevelRemotePeer

Keep

Replicated and encrypted volumes, backups to S3, shares

VolumeVolumeClaimBlobBackupImageShare

Configure

Delivered as files or environment

SecretConfigMap

Hardware

GPUs, displays and input, claimed by a workload

SeatDeviceDeviceClaim

Package

Signed packages in OCI registries, and GitOps

PackageReleaseRepositorySource

The machines

Nodes, their OS releases and rollouts

ClusterNodeNamespaceOSReleaseUpdatePlanNodeKey

Access

Who may do what, by kind, verb and namespace

IdentityRoleRoleBinding

From Kubernetes

What kubectl and helm send that kith keeps as sent and does not act on

KubeObject

Your own

New kinds with a schema, served like the built-in ones

KindDefinition

The page every node serves kith ui
The web UI: the kinds as stops on a line, three nodes and their replicas as a line map, a list of Workloads, and one Workload's form

Three nodes on one machine, photographed by ci/ui_shots.py. A form for every kind, drawn from its schema; an apply shows its diff first.

08 Security

Kept small, and said plainly.

A container is kept from most of the machine

It runs as a user that is not root, with no capabilities (on kith OS, only the one to take a port below 1024) and no new privileges, on a read-only image, behind a filter that refuses 40 system calls. A template has to say so to take any of that off.

Only signed things are taken

Packages and OS releases are refused without a signature by a key the cluster trusts. (An update stick is not signed: whoever is at the machine with one is its admin.) An image is held to a signature when its template names keys.

What is not defended is written down

Who is trusted with what, every gap that is known, and what was never reviewed: it is all in one file, and it does not flatter. Read SECURITY.md

09 Start

One machine is enough to begin.

kithd runs as you, with no root, on a Linux you already have. kith OS and more machines can come later.

on one machine
$ cargo build --release
$ export PATH=$PWD/target/release:$PATH
$ systemd-run --user --scope --quiet kithd &
$ kith apply -f examples/hello.yaml
$ kith get -w workload
$ kith logs workload/hello -f
and then another
$ kithd --listen 192.0.2.10:7443 --name alpha
$ kith node token
# on the other machine
$ kithd --join 192.0.2.10:7443 --token TOKEN --name beta
$ kith get node

The README has the rest Install kith OS The guide The design

10 Install

Answer once. It installs without asking.

The kith OS installer asks at the machine's console: which disk, what name, what address, which cluster. Answer on the install page instead, and it writes kith-install.yaml for the stick, in your browser. The machine then asks nothing.

What the installer would ask one stop for each, in the order the install page asks
  1. The stick Write the installer to a USB stick. Everything on it is lost.
  2. The disk Which one is erased: the machine's only disk, or one by its name or its serial.
  3. The name What the machine is called. Left empty, it names itself from its network card's address.
  4. The network Ask the network, or give it a fixed address, a way out and a DNS server.
  5. The cluster Start one, or join one with the address of a node and a token.
  6. Encryption Whether its state is locked. If it is, a recovery key is shown once.
  7. What it accepts The release key it takes updates from, and what the cluster may have it do.
  8. Writing The file goes on the stick, or is fetched from a URL by its digest.
  9. The key Written down when it appears on the console: it is shown that once.

Write your answers The install guide