{"id":7368,"library":"lightkube-models","title":"lightkube-models","description":"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.","status":"active","version":"1.35.0.8","language":"python","source_language":"en","source_url":"https://github.com/gtsystem/lightkube-models","tags":["kubernetes","models","resources","dataclasses","api-client","k8s"],"install":[{"cmd":"pip install lightkube-models","lang":"bash","label":"Install lightkube-models"}],"dependencies":[{"reason":"Required for package execution.","package":"python","optional":false,"version_constraint":">=3.9"},{"reason":"Provides 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`.","package":"lightkube","optional":true}],"imports":[{"wrong":"from lightkube.models.meta_v1 import ObjectMeta","symbol":"ObjectMeta","correct":"from lightkube.models.meta_v1 import ObjectMeta"}],"quickstart":{"code":"from lightkube.models.meta_v1 import ObjectMeta\nfrom lightkube.models.core_v1 import PodSpec, Container\n\n# Create a simple ObjectMeta instance\nmetadata = ObjectMeta(name='my-pod', namespace='default', labels={'app': 'my-app'})\nprint(f\"Created ObjectMeta: {metadata.name} in {metadata.namespace} with labels {metadata.labels}\")\n\n# Create a PodSpec\ncontainer = Container(name='nginx', image='nginx:latest')\npod_spec = PodSpec(containers=[container])\nprint(f\"Created PodSpec with container: {pod_spec.containers[0].name}\")\n","lang":"python","description":"Demonstrates how to import and instantiate basic Kubernetes model objects like `ObjectMeta` and `PodSpec` using their specific API group and version paths."},"warnings":[{"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`.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"`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.","severity":"gotcha","affected_versions":"All versions"},{"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`.","message":"Prior 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.","severity":"breaking","affected_versions":"<1.33.x.x"}],"env_vars":null,"search_vec":"'activ':55 'api':32,65,72 'api-cli':71 'client':19,73 'compat':51 'correspond':28 'current':54 'dataclass':70 'defin':36 'definit':8 'direct':27 'ensur':50 'instal':39,48 'k8s':74 'kubernet':10,31,47,64,67 'latest':63 'librari':20 'lightkub':2,18 'lightkube-model':1 'major.minor.micro':26 'match':44 'model':3,11,68 'modul':6,41 'new':57 'packag':25 'provid':7 'python':5 'releas':59 'resourc':13,69 'schema':33,66 'support':61 'target':46 'use':15 'user':37 'version':22,34,42,58","created_at":"2026-04-16T13:55:17.338058+00:00","updated_at":"2026-04-16T13:55:17.338058+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"/tmp/tmpp3znwra2/venv/lib/python3.12/site-packages/lightkube/models/_schema.py\", line 2, in <module>\n    from lightkube.core.schema import DictMixin, field, dataclass\nModuleNotFoundError: No module named 'lightkube.core'\n\nDuring handling of the above except"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.35.0.8","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/gtsystem/lightkube-models","docs":null,"changelog":null,"pypi":"https://pypi.org/project/lightkube-models/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}