httpx2-k8s
A small, strictly typed Kubernetes client for Python, built on HTTPX2.
It gives you synchronous and asynchronous clients, Pydantic models, and the familiar Kubernetes API groups—without generating a class for every operation.
Installation
pip install httpx2-k8s
Python 3.11 and newer are supported.
Quick start
Use your current kubeconfig context:
from httpx2_k8s import KubeClient
with KubeClient.from_kubeconfig() as client:
namespaces = client.core_v1.list_namespace()
print(namespaces.items)
Or use the credentials mounted inside a Pod:
from httpx2_k8s import KubeClient
with KubeClient.from_in_cluster() as client:
pods = client.core_v1.list_namespaced_pod("default")
There is also a native asynchronous client with the same API:
from httpx2_k8s import AsyncKubeClient
async with AsyncKubeClient.from_kubeconfig() as client:
namespaces = await client.core_v1.list_namespace()
What you get
- Strict Pydantic models and precise return types
- Synchronous and asynchronous APIs
- Kubeconfig, in-cluster, token, certificate, and exec-plugin authentication
- Core v1 and common stable API groups, including Apps, Batch, Networking, RBAC, Autoscaling, Policy, Storage, and AdmissionRegistration
- Typed custom resources, plus an
Unstructuredescape hatch - Pagination, watches, retries, patching, and server-side apply
- Pod logs, exec, attach, proxy, and port forwarding
- HTTP/2 for regular requests and Kubernetes-compatible WebSocket transports
The API follows Kubernetes group versions:
client.core_v1
client.apps_v1
client.autoscaling_v1
client.autoscaling_v2
Documentation
- Getting started
- Core v1 resources
- Custom resources
- Errors, retries, and watches
- Kubernetes API coverage
Development
uv sync
uv run pytest -m "not integration"
uv run pyrefly check
uv run ruff check .
The integration suite starts a real K3s control plane with Testcontainers:
TESTCONTAINERS_RYUK_DISABLED=true RUN_K3S=1 uv run pytest
License
httpx2-k8s is released under the BSD 3-Clause license.
Metadata
Release files for httpx2-k8s 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| httpx2_k8s-0.2.1.tar.gz | 384.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| httpx2_k8s-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 933.5 kB
Release files / httpx2_k8s-0.2.1.tar.gz
| Download URL | httpx2_k8s-0.2.1.tar.gz |
|---|---|
| Size | 384.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfc2a43e72f61af2cfe242264811a85fb8aaac65676a7caab59340a0b010810f
|
|
BLAKE2b-256 checksum How to use checksums |
4e427bf800eba9fb8db83ebdadbd116c1e919cced76f19b6387897564a6e6a65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / httpx2_k8s-0.2.1-py3-none-any.whl
| Download URL | httpx2_k8s-0.2.1-py3-none-any.whl |
|---|---|
| Size | 549.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ddb3f432c49673e19ad713b0c475c9b3213b085d60c53fad1adedc9d8071b9e
|
|
BLAKE2b-256 checksum How to use checksums |
0106f0376229fdae3c0ada722dbd90964ec975ddbc049fd0e95ea1958628866e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|