kubernetes
The official, generated Python client for the Kubernetes API
Repository Health
Technical Analysis
The kubernetes PyPI package is the official Python client library for the Kubernetes API, maintained under the kubernetes-client organization alongside sibling clients for Go, Java, and other languages. Like those siblings, its API surface (kubernetes/client/) is largely generated from the Kubernetes OpenAPI/Swagger specification, giving full coverage of every core and extension API resource with typed models rather than hand-maintained bindings that lag the API.
Beyond the generated REST client, the package includes hand-written convenience layers: kubernetes.config for loading kubeconfig files or in-cluster service-account credentials, kubernetes.watch for streaming resource-change events, kubernetes.stream for exec/attach/port-forward over the Kubernetes API, a leaderelection module for building highly-available controllers, and a separate kubernetes.aio asyncio-based client alongside the default synchronous one.
What You Get
- A generated REST client (
kubernetes.client) with typed models and API classes covering every Kubernetes API group and version kubernetes.configfor loading credentials from a kubeconfig file or from in-cluster service-account tokens automaticallykubernetes.watchfor consuming Kubernetes watch streams (resource create/update/delete events) as a Python iteratorkubernetes.streamfor exec, attach, and port-forward operations against running pods over the Kubernetes API- A
leaderelectionmodule for building highly-available controllers, and akubernetes.aiopackage providing an asyncio-native client alongside the default synchronous one
Common Use Cases
- Writing a Kubernetes controller or operator in Python that watches and reconciles custom or core resources
- Building an internal CLI or automation script that creates, updates, or deletes Kubernetes resources programmatically
- Streaming live pod logs or exec-ing into a running container from a Python script or web backend
- Building a dashboard or internal tool that reads cluster state (pods, deployments, nodes) via the generated client
- Writing an asyncio-based Kubernetes controller using the
kubernetes.aioclient for high-concurrency reconciliation loops
Under The Hood
Architecture - The package splits a large generated surface (kubernetes/client/, produced from the Kubernetes OpenAPI spec via scripts/update-client.sh and the shared swagger.json.unprocessed) from hand-written convenience modules: config/ (credential loading), watch/ (streaming watch events), stream/ (exec/attach/port-forward), leaderelection/ (HA controller support), informer/, dynamic/ (a dynamic, non-generated client for arbitrary/custom resources), and aio/ (the asyncio client built parallel to the sync one).
Tech Stack - Pure Python (99.9%), generated with OpenAPI Generator against the upstream Kubernetes Swagger/OpenAPI spec; the CLIENT_VERSION in setup.py is kept in lockstep with the Kubernetes API version it targets rather than following independent semver.
Code Quality - The kubernetes/e2e_test/ and per-module test/ directories provide both unit and end-to-end coverage (the e2e suite runs against a real or kind-provisioned cluster), and CI/CD is driven by k8s-ci-robot, the shared Kubernetes-org bot, reflecting the project’s integration with upstream Kubernetes release tooling and SIG API Machinery review process.
API Design - Because most of the client is generated directly from the OpenAPI spec, method and model names track the Kubernetes API’s own resource/verb naming exactly (e.g. CoreV1Api.list_namespaced_pod), which is highly consistent but verbose; the hand-written config, watch, stream, and dynamic modules exist specifically to smooth over ergonomics the generated client doesn’t cover on its own (auth loading, streaming, and working with resources not known at generation time).
Used by 10 apps in this directory
Agno
Devops · AI Development · Automation
Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.
Apache Airflow
Data Engineering
Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.
authentik
Authentication · Security
The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.
Keep
Devops · Automation · Monitoring
The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.
Langflow
AI Agents · AI Development
Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.
MLflow
AI Development · Monitoring
The open source AI engineering platform for debugging, evaluating, monitoring, and optimizing production LLMs and agents at scale.
nao
AI Development · Analytics
Build and deploy an open-source analytics agent that understands your data warehouse and answers business questions in plain English.
OpenHands
AI Code Assistants · AI Development
The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.
OpenSandbox
Developer Tools · Security
Secure, fast, and extensible sandbox runtime for AI agents with multi-language SDKs and Docker/Kubernetes runtimes.