The repository or configuration that created this release differ from a previous release. View details.
This release is a pre-release and may not be stable for production use.
Kubex
Documentation: https://kubex.codemageddon.me/
Kubex is a Kubernetes client library for Python inspired by kube.rs. It is built on top of Pydantic and is async-runtime agnostic.
Why Kubex?
Performance
Kubex is dramatically faster than kubernetes-asyncio, the most popular async Kubernetes client for Python. Benchmarks against a K3s 1.35.4 cluster (see benchmarks/):
| Scenario | kubernetes-asyncio | kubex (aiohttp) | kubex (httpx) | Speedup |
|---|---|---|---|---|
| Single GET | 61 ms | 6 ms | 26 ms | 10× |
| List 100 pods | 2,813 ms | 73 ms | 102 ms | 38× |
| List 500 pods | 14,441 ms | 351 ms | 410 ms | 41× |
| Watch 50 events | 3,957 ms | 562 ms | 1,764 ms | 7× |
Kubex also uses ~47% less heap memory and makes up to ~5x fewer allocations, reducing GC pressure in long-running controllers and operators.
Fully typed
Every Kubernetes resource is a Pydantic v2 model with proper type annotations — spec fields, status fields, enums, and nested objects are all typed, not dict[str, Any]. Combined with mypy --strict support, you get IDE autocompletion and compile-time safety instead of runtime KeyErrors.
from kubex.api import Api
from kubex.client import create_client
from kubex.k8s.v1_35.core.v1.pod import Pod
async with await create_client() as client:
api: Api[Pod] = Api(Pod, client=client)
pod = await api.get("my-pod", namespace="default")
# pod.spec, pod.status, pod.metadata are all fully typed
Multi-version Kubernetes support
Kubex ships separate model packages for Kubernetes 1.32 through 1.38. You can depend on exactly the versions you need, or use multiple versions simultaneously — useful when managing clusters at different upgrade stages:
from kubex.k8s.v1_34.apps.v1.deployment import Deployment as Deployment134
from kubex.k8s.v1_35.apps.v1.deployment import Deployment as Deployment135
Each package is generated from the official OpenAPI spec, so models always match the wire schema of the target cluster.
Async-runtime agnostic
Kubex works with both asyncio and trio (via httpx), with no framework lock-in.
Completed Features:
- Basic API interface that allows interaction with almost any Kubernetes resources and their methods.
- In-cluster client authorization with token refreshing.
- Basic support for kubeconfig files.
httpxandaiohttpas an underlying http-client support.asyncioandtrioasync runtime support (onlyhttpxclient is supported fortrio).- Comprehensive, fully-typed Kubernetes resource models (1.32–1.38) generated from the OpenAPI spec via a built-in code generator.
- Custom Resource Definitions (CRDs) — define a Pydantic model inheriting from
NamespaceScopedEntityorClusterScopedEntitywith__RESOURCE_CONFIG__and useApi[T]for full CRUD, watch, and subresource access. No code generation required. Seeexamples/custom_resource.pyand the Custom Resources docs. ClientOptions— per-client HTTP configuration:proxy(single URL string or per-scheme{"http": …, "https": …}dict),keep_alive/keep_alive_timeout,buffer_size(aiohttp read buffer),ws_max_message_size(WebSocket frame cap for exec/attach/portforward),pool_size(total connection pool),pool_size_per_host, andtrust_env(opt-in toHTTP_PROXY/HTTPS_PROXY/NO_PROXYenv vars and~/.netrcproxy credentials on both backends). Passoptions=ClientOptions(…)tocreate_client(). Seeexamples/client_options.py.
Experimental — WebSocket subresources. The
exec,attach, andportforwardAPIs described below are still under active development. Their public surface (method signatures, accessor shape, session helpers) may change in future releases without notice.
- Pod
execsubresource over WebSocket — one-shotrun()for collecting output, andstream()for interactive sessions with stdin/resize. Both acceptcommand,container,stdout,stderr, andrequest_timeout;run()takesstdinas bytes (orNoneto skip), whilestream()takesstdinandttyas bools and exposessession.stdin.write()/close(),session.stdout/session.stderras async iterators,session.resize(width=, height=), andawait session.wait_for_status()(resolves to aStatusmodel when the server emits one on the error channel, orNoneif the connection closes first; correspondingly,result.exit_codeis0on success, the parsed integer for a non-zero exit, orNonewhen no recognisable exit information is present —Nonedoes not imply success). Trio is supported only via thehttpxclient; theaiohttpbackend is asyncio-only and raises onconnect_websocket()if used with trio. Requires Kubernetes ≥1.30 (uses the v5 channel protocol; install viakubex[httpx-ws]to pull inhttpx-ws(the plainkubex[httpx]extra omits it so non-WebSocket installs stay slim)). Seeexamples/exec_pod.py. - Pod
attachsubresource over WebSocket —stream()attaches to an existing container process (stdin/stdout/stderr) without issuing a new command. Exposes the sameStreamSessioninterface asexec(session.stdin.write()/close(),session.stdout/session.stderras async iterators,session.resize(width=, height=),await session.wait_for_status()). Onlystream()is provided — there is norun(). The container must be created withstdin=Truein its spec for stdin writes to reach the process. Requireskubex[httpx-ws](oraiohttp). Seeexamples/attach_pod.py. - Pod
portforwardsubresource over WebSocket — two-level API:api.portforward.forward(name, ports=[…])yields aPortForwarderwith oneanyio.abc.ByteStreamper port (pf.streams[port]) and a per-port error iterator (pf.errors[port]);api.portforward.listen(name, port_map={remote_port: local_port})opens local TCP listener sockets and copies bytes bidirectionally between each accepted local connection and a fresh portforward WebSocket session (one session per connection, matchingkubectl port-forwardsemantics). Requireskubex[httpx-ws](oraiohttp). Seeexamples/portforward_pod.py.
from kubex.api import Api
from kubex.client import create_client
from kubex.k8s.v1_35.core.v1.pod import Pod
async with await create_client() as client:
api: Api[Pod] = Api(Pod, client=client, namespace="default")
result = await api.exec.run("my-pod", command=["echo", "hello"])
print(result.stdout, result.exit_code)
Metadata
Release files for kubex 0.1.0b6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Change of provenance
The repository or configuration that created these release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kubex-0.1.0b6.tar.gz | 100.4 kB | With provenance | Details for kubex-0.1.0b6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kubex-0.1.0b6-py3-none-any.whl | Python 3 | none | any | Details for kubex-0.1.0b6-py3-none-any.whl |
Total release size: 233.0 kB
Release files / kubex-0.1.0b6.tar.gz
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | kubex-0.1.0b6.tar.gz |
|---|---|
| Size | 100.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
811ae9ee57a42b3014c49c56081bd204a8235d12cfa91d4159745594aca39062
|
|
BLAKE2b-256 checksum How to use checksums |
33ad33969ac99187833a4b11863b4e3406513b1a80873b362f727684f48af0fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / kubex-0.1.0b6-py3-none-any.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | kubex-0.1.0b6-py3-none-any.whl |
|---|---|
| Size | 132.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a58e62e00336589f6e56e2a283943b6134af0a7af0d16644e711e48c4a125e7
|
|
BLAKE2b-256 checksum How to use checksums |
94069f0de605ab35185b81aed3274850c1246c98f1fa8a268b8fa369e3270e47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logSecurity for kubex 0.1.0b6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Change of provenance
The repository and configuration that created this release differ from a previous release.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Repository
- Removed 0.1.0b5 github.com/codemageddon/kubex
- Added 0.1.0b6 github.com/kubex-py/kubex
Attestation for kubex-0.1.0b6.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.