Install & Compatibility
Where this runs
tested against v18.20.2 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 94.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.3s · import 0.000s · 94MB
93MB installed
● package 93MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CustomResource
✓ from crd_typed import CustomResource
✗ from kubernetes.client.models import V1Deployment
Any
✓ from crd_typed import Any
Dict
✓ from crd_typed import Dict
Create a strongly-typed Kubernetes Deployment object using kubernetes-typed stubs.
from kubernetes import client
from kubernetes.client.models import V1Deployment
def create_deployment() -> V1Deployment:
return V1Deployment(
api_version="apps/v1",
kind="Deployment",
metadata=client.V1ObjectMeta(name="example"),
spec=client.V1DeploymentSpec(
replicas=1,
selector=client.V1LabelSelector(match_labels={"app": "example"}),
template=client.V1PodTemplateSpec(
metadata=client.V1ObjectMeta(labels={"app": "example"}),
spec=client.V1PodSpec(
containers=[client.V1Container(name="nginx", image="nginx:1.14.2")]
)
)
)
)
Debug
Known issues
gotchakubernetes-typed provides stubs for the kubernetes Python client; it does NOT replace the full kubernetes library. You must also install kubernetes.fixpip install kubernetes kubernetes-typed
affects: all
breakingVersion 18.20.0 introduced many changes; pin to exact minor if you encounter issues. v18.20.1 fixed a too-strict mypy version pin; v18.20.2 fixed circular imports in TypedDict definitions.fixUpgrade to 18.20.2: pip install kubernetes-typed==18.20.2
affects: >=18.20.0, <18.20.2
gotchaImport paths for Kubernetes models must follow the official kubernetes client paths (e.g., kubernetes.client.models.V1Deployment). Using kubernetes-typed does not change these paths.fixUse correct import: from kubernetes.client.models import V1Deployment
affects: all
Upgrade
Version history
18.20.2latest on PyPI · released Sep 2, 2024
Audit
Dependencies
kubernetesrequiredRequired runtime dependency; provides the Kubernetes client library that stubs target.
mypyrequiredRequired for type-checking; kubernetes-typed provides a mypy plugin.