# k8s-render — Helm and Kustomize as WebAssembly

Used by the [Helm and Kustomize renderer](/tools/helm-kustomize/). `k8s-render.wasm.gz` is one Go
program (GOOS=js, GOARCH=wasm), gzip-compressed; the page unpacks it with the browser's
DecompressionStream and runs it with Go's own `wasm_exec.js` (from the Go 1.26 distribution).

- **Helm v4.2.3** — https://github.com/helm/helm, © The Helm Authors, Apache License 2.0
  (LICENSE.txt). Its chart loader, `.helmignore` rules, values merging (`strvals`, `MergeValues`
  order), dependency processing, values-schema validation, template engine (Sprig and Helm's own
  functions) and manifest sorter are used as they are.
- **Kustomize API v0.21.1 / kyaml v0.21.1** — https://github.com/kubernetes-sigs/kustomize,
  © The Kubernetes Authors, Apache License 2.0 — the `krusty` builder, as in kustomize and
  `kubectl kustomize` v5.8.1, over an in-memory file system.

## Changes to Helm

So that the build does not link the Kubernetes client (client-go, which would triple its size),
`build.sh` copies the Helm module and changes three things:

1. `pkg/chart/common/capabilities.go` — Helm builds the default `.Capabilities.APIVersions` list
   from client-go's scheme at start-up. The list is generated once from the unmodified Helm by
   `gen-versionset.go` and compiled in, so it is the same list.
2. `internal/version/clientgo.go` — the client-go version (used for the default Kubernetes
   version, v1.36.0) is a constant, `v0.36.1`, the version Helm v4.2.3's go.mod requires.
3. `pkg/engine` — the cluster-backed `lookup` function and the two constructors that take a REST
   config are removed. `helm template` never has a cluster either, and there `lookup` returns an
   empty map, as it does here.

The wrapper (`main.go`, `util.go`) only converts between JSON and Helm's/Kustomize's Go types,
mirrors what `helm template` does after rendering (NOTES.txt, sorting, hooks, `--include-crds`,
`--skip-tests`, `--no-hooks`), and captures warnings.

## Build files published with this build

[`build.sh`](build-source/build.sh), [`main.go`](build-source/main.go),
[`util.go`](build-source/util.go), [`gen-versionset.go`](build-source/gen-versionset.go),
[`go.mod`](build-source/go.mod), [`go.sum`](build-source/go.sum) — also in the site's repository
under `tools/wasm/k8s-render/`. `./build.sh site/static/wasm/k8s-render` rebuilds it (Go 1.26).
