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
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file httpx2_k8s-0.1.0.tar.gz.
File metadata
- Download URL: httpx2_k8s-0.1.0.tar.gz
- Upload date:
- Size: 77.4 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c726ba7a5e3babd48267a644b178c9646edaad78778dcc34ea4c9f223f5a156
|
|
| MD5 |
4578ea606bb20c4daf728a0090936865
|
|
| BLAKE2b-256 |
a2786e32b3a3f05cbb1ccccc8b821d43fda8e58642e9bf44c95c1c2736538dac
|
File details
Details for the file httpx2_k8s-0.1.0-py3-none-any.whl.
File metadata
- Download URL: httpx2_k8s-0.1.0-py3-none-any.whl
- Upload date:
- Size: 116.5 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2390f0737d054611168d939dc3cc449371629d798d32a75f215536f25dc9862b
|
|
| MD5 |
c13faa4c675837efbb2baaa56865147c
|
|
| BLAKE2b-256 |
4e74d6801dd41d84c466be19c1a2db3381f88d3e970e1945f0890b5ff4da1fc2
|