The `kubernetes-types` package provides comprehensive TypeScript definitions for Kubernetes API resources. It generates these definitions directly from the official Kubernetes OpenAPI specifications, ensuring accuracy and up-to-date type information. The current stable version is 1.30.0, aligning with Kubernetes API version 1.30.x. This package adheres to a strict versioning policy: its major and minor versions directly correspond to the target Kubernetes API version, while the patch version is reserved for updates to the generated types themselves. This approach ensures developers can reliably match their type definitions to their Kubernetes cluster's API version, preventing common runtime errors related to schema mismatches. It is a critical tool for building type-safe Kubernetes clients, controllers, and automation scripts in TypeScript, distinguishing itself by its direct generation from the official OpenAPI specs and strict version adherence rather than manual maintenance.
npm install kubernetes-typesVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import and define basic Kubernetes Pod and Deployment resources using the provided TypeScript types, including common metadata and container specifications, and environment variables.
Always install the `kubernetes-types` version that precisely matches the major and minor version of your target Kubernetes cluster API. For example, for a Kubernetes v1.30 cluster, use `kubernetes-types@1.30.x`. Review Kubernetes API documentation for changes between versions before upgrading.
Verify your cluster's Kubernetes version (`kubectl version`) and align your `kubernetes-types` package version accordingly. Use a strict version specifier (e.g., `"kubernetes-types": "~1.30.0"` or `"^1.30.0"`) to prevent unintended minor version upgrades that could introduce API mismatches.
Always use specific deep imports for each Kubernetes resource, such as `import { Pod } from 'kubernetes-types/core/v1'` or `import { Deployment } from 'kubernetes-types/apps/v1'`. Consult the Kubernetes API reference or the package's documentation to determine the correct import path for each type.Check the Kubernetes API documentation for the specific API version you are targeting. Ensure your `kubernetes-types` version matches your cluster's version. The field might be deprecated, removed, or belong to a different object or API group.
Correct the import path to reflect the Kubernetes API group and version of the desired type. For example, change `import { SomeType } from 'kubernetes-types'` to `import { SomeType } from 'kubernetes-types/<api-group>/<api-version>'` (e.g., `kubernetes-types/core/v1` for `Pod`).Verify the exact API group and version path. Kubernetes resources are structured under `/apis/<group>/<version>` or `/api/<version>` for core resources. Ensure the path in your import statement matches this structure precisely, e.g., `kubernetes-types/apps/v1` for `Deployment` or `kubernetes-types/meta/v1` for `ObjectMeta`.
No dependency data recorded yet.