Registry / devops / lightkube-models

lightkube-models

JSON →
library1.35.0.8pypypiunverified

This Python module provides definitions of Kubernetes models and resources for use with the `lightkube` client library. The version of this package (major.minor.micro) directly corresponds to the Kubernetes API schema version it defines. Users should install the module version that matches their target Kubernetes installation or ensure compatibility. It is currently active, with new versions released to support the latest Kubernetes API schemas.

pip install lightkube-models
INSTALL
IMPORT
SIG · LIGHTKUBE-MODELS
L
lightkube-models
devopspythonv1.35.0.8
Install
1.6s avg
Import
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.35.0.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 20.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.000s · 21MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ObjectMeta
from lightkube.models.meta_v1 import ObjectMeta
from lightkube.models.meta_v1 import ObjectMeta

Demonstrates how to import and instantiate basic Kubernetes model objects like `ObjectMeta` and `PodSpec` using their specific API group and version paths.

from lightkube.models.meta_v1 import ObjectMeta from lightkube.models.core_v1 import PodSpec, Container # Create a simple ObjectMeta instance metadata = ObjectMeta(name='my-pod', namespace='default', labels={'app': 'my-app'}) print(f"Created ObjectMeta: {metadata.name} in {metadata.namespace} with labels {metadata.labels}") # Create a PodSpec container = Container(name='nginx', image='nginx:latest') pod_spec = PodSpec(containers=[container]) print(f"Created PodSpec with container: {pod_spec.containers[0].name}")
Debug
Known issues
gotchaThe version of `lightkube-models` (first three parts: major.minor.micro) directly corresponds to the Kubernetes API schema version it encapsulates. Mismatching this version with your Kubernetes cluster's version can lead to schema validation errors or missing fields.
fix
Install a `lightkube-models` version that aligns with your target Kubernetes cluster API version. For example, for Kubernetes 1.29, use `lightkube-models>=1.29,<1.30`.
affects: All versions
gotcha`lightkube.models` provides pure dataclass representations of Kubernetes schemas. The `lightkube` client (from the `lightkube` library) often expects `lightkube.resources` classes, which are subclasses of models with additional metadata for client operations.
fix
When interacting with the `lightkube` client, prefer importing from `lightkube.resources.{group}_{version}` (e.g., `from lightkube.resources.core_v1 import Pod`) rather than `lightkube.models`. If you only need schema definition without client interaction, `lightkube.models` is appropriate.
affects: All versions
breakingPrior to `lightkube-models` version 1.33, resource models did not automatically set `apiVersion` and `kind` during instantiation. These fields had to be manually provided when creating objects.
fix
For `lightkube-models` versions older than 1.33, ensure `apiVersion` and `kind` are explicitly set in the model's constructor, or upgrade to a `lightkube-models` version >= 1.33, which sets these automatically during `post_init`.
affects: <1.33.x.x
Upgrade
Version history
1.35.0.8latest on PyPI · released Dec 25, 2025
Audit
Dependencies
pythonrequiredRequired for package execution.
lightkubeoptionalProvides the Kubernetes API client that uses these models. While not a direct dependency of `lightkube-models`, they are designed to be used together, and `lightkube` itself depends on `lightkube-models`.
Agent activity
13 hits · last 30 days
node
12
Resources
lightkube-models — pip install lightkube-models · libregistry