I ported Kubernetes to the browser
- Project Overview:
- Named webernetes, it is a highly experimental, browser-based partial port of Kubernetes written in TypeScript, running entirely client-side without backend server components.
- Developed at ngrok to provide a long-term, low-maintenance simulator for creating interactive and visual educational content about Kubernetes.
- Architecture & Features:
- Includes ports of core Kubernetes controllers (deployment, ReplicaSet, pod scheduler, and namespace) along with a partial port of the
kubeletbinary. - Features a simulated browser-based container network interface (CNI) for pod-to-pod communication over DNS/IP and a browser container runtime interface (CRI).
- Avoids pulling massive images from registries like Docker Hub by utilizing a custom browser-based registry defined via a TypeScript API.
- Includes ports of core Kubernetes controllers (deployment, ReplicaSet, pod scheduler, and namespace) along with a partial port of the
- Why WebAssembly (Wasm) Was Not Used:
- A simple "hello, world!" Go binary compiled to Wasm is ~540KiB gzipped, whereas the entire
webernetesproject is much lighter at ~140KiB gzipped. - Compiling the real Kubernetes codebase to Wasm failed due to compile-time errors from missing system-level APIs in the browser.
- A simple "hello, world!" Go binary compiled to Wasm is ~540KiB gzipped, whereas the entire
- Development & LLM Challenges:
- Around 90% of the code was translated line-for-line from the original Kubernetes Go source using LLMs, though the author had to strictly review every line.
- LLMs consistently introduced errors such as cutting corners (e.g., replacing complex caches with a simple JavaScript
Map), adding unrequested helper functions, and omitting cases in table tests.
- Testing & Behavioral Parity:
- To ensure lexical similarity translated to correct execution, hundreds of differential tests were written.
- These tests validate behavioral parity by running the exact same client code against both
webernetesand a realk3scluster using the officialkubernetes-client/javascriptlibrary.