This repository serves as an example and template for building and publishing extensions for the Freelens application.
It demonstrates how to add support for custom Kubernetes resources by implementing cluster pages, list views, and detail panels for Custom Resource Definitions (CRDs). Each resource is accessible from the Freelens sidebar, with status conditions, spec fields, and related objects displayed in the detail view.
Notable patterns demonstrated in this repository:
-
Multiple API versions of the same CRD -- the
Exampleresource is implemented for bothv1alpha1andv1alpha2, each with separate typed interfaces, detail views, list pages, and context menu items. The v1alpha1 to v1alpha2 migration also illustrates a field rename with inverted semantics (activetosuspended). -
Auto-detection of the available API version -- the
createAvailableVersionPagehelper tries each registered version in priority order at runtime, renders the page for the first version whose store is available in the cluster, and shows a friendly message if the CRD is not installed. -
Static methods instead of instance methods -- Freelens creates plain object copies of Kubernetes resources rather than class instances, so all per-object logic is implemented as
staticmethods on the KubeObject subclass (e.g.Example.getActive(object)). -
Error boundary with
withErrorPage-- every component render is wrapped in awithErrorPage(props, fn)helper that catches errors, logs them, and renders a graceful error UI instead of crashing the panel. -
Persisted preferences with MobX --
ExamplePreferencesStoreshows how to persist extension settings across restarts usingCommon.Store.ExtensionStorewith MobX@observablefields.
Visit the wiki page about creating extensions for more information.
- Kubernetes >= 1.24
- Freelens >= 1.8.0
| API Version | Kind | Scope | Description |
|---|---|---|---|
| v1alpha1 | Example |
Namespaced | Example custom resource (v1alpha1) |
| v1alpha2 | Example |
Namespaced | Example custom resource (v1alpha2) |
To install Custom Resource Definitions for this example run:
kubectl apply -k examples/v1alpha1/crds
kubectl apply -k examples/v1alpha2/crdsExample resources for testing:
kubectl apply -k examples/v1alpha2/test
# or
kubectl apply -k examples/v1alpha1/testTo install, open Freelens and go to Extensions (ctrl+shift+E or
cmd+shift+E), then search for and install
@freelensapp/example-extension.
Alternatively, open the following URL in the browser to install directly:
freelens://app/extensions/install/%40freelensapp%2Fexample-extension
You can build the extension from this repository.
Use NVM, mise-en-place, or windows-nvm to install the required Node.js version.
From the root of this repository:
nvm install
# or
mise install
# or
winget install CoreyButler.NVMforWindows
nvm install 24.15.0
nvm use 24.15.0Install pnpm:
corepack install
# or
curl -fsSL https://get.pnpm.io/install.sh | sh -
# or
winget install pnpm.pnpmpnpm i
pnpm build
pnpm packOne script to build and pack the extension for testing:
pnpm pack:devThe tarball will be placed in the current directory. In Freelens, navigate
to the Extensions page and provide the path to the tarball, or drag and
drop the .tgz file into the Freelens window.
pnpm lint:checkor
pnpm trunk:checkand
pnpm build
pnpm knip:checkIn the Freelens working repository:
rm -f *.tgz
pnpm i
pnpm build
pnpm pack -rThen in the extension repository:
echo "overrides:" >> pnpm-workspace.yaml
for i in ../freelens/*.tgz; do
name=$(tar zxOf $i package/package.json | yq -r .name)
echo " \"$name\": $i" >> pnpm-workspace.yaml
done
pnpm clean:node_modules
pnpm buildCopyright (c) 2025-2026 Freelens Authors.