lightkube-models

1.35.0.8 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →