TypeScript type definitions for Kubernetes resources, generated on demand from the OtterScale Backend.
This package connects to the Backend's ResourceService (ConnectRPC), discovers every registered GVK (Group / Version / Kind) in the target cluster, and compiles their JSON Schemas into .d.ts declaration files for use by the frontend dashboard.
Before running the sync, you'll need the following three values:
| Item | Description |
|---|---|
| Cluster Name | Identifier of the target Kubernetes cluster within OtterScale |
| API Base URL | Endpoint of the OtterScale Backend |
| Access Token | Bearer token (JWT) issued by Keycloak |
💡 The access token can be obtained from the Keycloak
otterscale-dashboardservice account. Tokens are short-lived and must be refreshed once expired.
pnpm installYou can provide credentials either as CLI flags or as environment variables.
pnpm run sync \
--cluster <cluster-name> \
--baseUrl <api-base-url> \
--token <api-bearer-token>Short-form equivalents:
pnpm run sync \
-c <cluster-name> \
-u <api-base-url> \
-t <api-bearer-token>export CLUSTER_NAME=<cluster-name>
export API_BASE_URL=<api-base-url>
export API_BEARER_TOKEN=<api-bearer-token>
pnpm run sync| Flag | Environment variable |
|---|---|
-c, --cluster |
CLUSTER_NAME |
-u, --baseUrl |
API_BASE_URL |
-t, --token |
API_BEARER_TOKEN |
When executed, scripts/sync.ts performs the following steps:
All .d.ts and .js files under src/ are deleted so the output reflects exactly what this run produces — no leftovers from CRDs that have since been removed from the cluster.
Calls ResourceService.Discovery to list every API resource in the cluster (built-ins and CRDs alike).
- ✅ Keeps only resources whose API Group is in the
INCLUDE_GROUPSallowlist (e.g.apps,ceph.rook.io,kubevirt.io,serving.kserve.io). - 🚫 Skips subresources such as
pods/statusanddeployments/scale. - 📋 Reports any groups outside the allowlist under
🚫 Skipped Groupsin the console output.
For every matching GVK, calls ResourceService.Schema to retrieve its JSON Schema.
- Deep-sorts schema properties with
sort-keysfor deterministic, diff-friendly output. - Compiles each schema into a TypeScript interface via
json-schema-to-typescript. - Emits two files per GVK into
src/:<group>.<version>.<Kind>.d.ts— the type declaration<group>.<version>.<Kind>.js— an empty module stub (required for ESM runtime resolution)
- The Kubernetes core group (empty string) is named
core, e.g.core.v1.Pod.d.ts.
Writes all GVK modules — in sorted order — into src/index.d.ts and src/index.js as the package's entry point.
Prints success / failure counts. Exits with code 1 if any GVK failed to generate.
src/
├── index.d.ts # Re-exports all types
├── index.js # Re-exports all runtime stubs
├── <group>.<version>.<Kind>.d.ts
├── <group>.<version>.<Kind>.js
├── ...
To include a newly deployed CRD group (e.g. from a freshly installed Operator):
- Open
scripts/sync.ts. - Add the group name to the
INCLUDE_GROUPSset. - Re-run
pnpm run sync.
- 🔁 The script fully rebuilds
src/on every run. Do not hand-edit any file undersrc/— your changes will be lost. - 💥 On failure,
src/may be left empty. Because cleanup happens up front, an aborted run (e.g. Backend unreachable, Discovery RPC error) can leave the directory bare. Simply re-run once the issue is fixed. - 🔐 The built-in default token is for local testing only. Always supply a fresh token via flag or environment variable in any non-local environment.