Skip to main content

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 Unstructured escape 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

httpx2_k8s-0.2.1.tar.gz (384.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httpx2_k8s-0.2.1-py3-none-any.whl (549.2 kB view details)

Uploaded Python 3

File details

Details for the file httpx2_k8s-0.2.1.tar.gz.

File metadata

  • Download URL: httpx2_k8s-0.2.1.tar.gz
  • Upload date:
  • Size: 384.3 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

Hashes for httpx2_k8s-0.2.1.tar.gz
Algorithm Hash digest
SHA256 cfc2a43e72f61af2cfe242264811a85fb8aaac65676a7caab59340a0b010810f
MD5 f4bb4a1627c91b824c96d2911b9aa394
BLAKE2b-256 4e427bf800eba9fb8db83ebdadbd116c1e919cced76f19b6387897564a6e6a65

See more details on using hashes here.

File details

Details for the file httpx2_k8s-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: httpx2_k8s-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 549.2 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

Hashes for httpx2_k8s-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ddb3f432c49673e19ad713b0c475c9b3213b085d60c53fad1adedc9d8071b9e
MD5 cc8fafe6aae6511f82368c95ebb85508
BLAKE2b-256 0106f0376229fdae3c0ada722dbd90964ec975ddbc049fd0e95ea1958628866e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page