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.0.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.0-py3-none-any.whl (549.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: httpx2_k8s-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 46b50bbfd4271c0898da14af8873bbd59e51c1f0ef9197bbaaaf214621d98df8
MD5 24301aed196d2692c7e0539db639cb82
BLAKE2b-256 e5f88fe30a3633db850a4811be863cf8d3c658d034a9014ec43a5f3c4b16302a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: httpx2_k8s-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 549.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1d45f53f098972c8b5d44480a810141cc65da0f499a58c7253aa1e0ef77df74
MD5 9364e7db5cb817e82c977648c1c69ee0
BLAKE2b-256 a037a7a29b9fd8e680bf7e248fecdd0b3590417769426d3942a83ec36cd9868a

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