Skip to main content

Kubernetes Python Client

Build status PyPI version Docs codecov pypi supported versions Client Capabilities Client Support Level

Asynchronous (AsyncIO) client library for the Kubernetes API.

This library is created in the same way as the official https://github.com/kubernetes-client/python but uses asynchronous version of OpenAPI generator. My motivation is described here: https://github.com/kubernetes-client/python/pull/324

Installation

From PyPi directly:

pip install kubernetes_asyncio

It requires Python 3.10+

Example

To list all pods:

import asyncio
from kubernetes_asyncio import client, config
from kubernetes_asyncio.client.api_client import ApiClient


async def main():
    # Configs can be set in Configuration class directly or using helper
    # utility. If no argument provided, the config will be loaded from
    # default location.
    await config.load_kube_config()

    # use the context manager to close http sessions automatically
    async with ApiClient() as api:

        v1 = client.CoreV1Api(api)
        print("Listing pods with their IPs:")
        ret = await v1.list_pod_for_all_namespaces()

        for i in ret.items:
            print(i.status.pod_ip, i.metadata.namespace, i.metadata.name)


if __name__ == '__main__':
    asyncio.run(main())

More examples, including asynchronous multiple watch or tailing logs from pods, can be found in examples/ folder.

Documentation

https://kubernetes-asyncio.readthedocs.io/

Microsoft Windows

In case this library is used against Kubernetes cluster using client-go credentials plugin, the default asyncio event loop is SelectorEventLoop. This event loop selector, however, does NOT support pipes and subprocesses, so exec_provider.py::ExecProvider is failing. In order to avoid failures the ProactorEventLoop has to be selected. The ProactorEventLoop can be enabled via WindowsProactorEventLoopPolicy.

Application's code needs to contain following code:

import asyncio

asyncio.set_event_loop_policy(
    asyncio.WindowsProactorEventLoopPolicy()
)

Versions

This library is versioned in the same way as the synchronous library. The schema version has been changed with version v18.20.0. Now, first two numbers from version are Kubernetes version (v.1.18.20). The last number is for changes in the library not directly connected with K8s.

Development

# Create and activate virtual environment
uv venv
source .venv/bin/activate

# Install dependencies
uv sync

# Run ruff
ruff check .
ruff format --diff .

# Run tests
pytest

Release files for kubernetes-asyncio 36.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kubernetes-asyncio 36.1.0
File Size Uploaded
kubernetes_asyncio-36.1.0.tar.gz 1.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for kubernetes-asyncio 36.1.0
File Interpreter ABI Platform
kubernetes_asyncio-36.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 4.5 MB

Release files / kubernetes_asyncio-36.1.0.tar.gz

Download URL kubernetes_asyncio-36.1.0.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
6d979d82e5ebe490bea298e7843732a2336173236bae28e200434889443d4443
BLAKE2b-256 checksum
How to use checksums
60459e15f4268454636aee32d92ddeaa7128c71100308644bc79685292c1efcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 4, 2026.

Transparency log

Release files / kubernetes_asyncio-36.1.0-py3-none-any.whl

Download URL kubernetes_asyncio-36.1.0-py3-none-any.whl
Size 3.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
6d25915d1abff24fceda551a502208d986f674d72586297aa58bc7d55e7feaf3
BLAKE2b-256 checksum
How to use checksums
b2dc695601e3a6f08ca3d6035d300a944974c17084050591faec6e1de39e4a4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 4, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

36.1.0 This release

2 release files

35.0.1

2 release files

35.0.0

2 release files

34.3.3

2 release files

34.3.2

2 release files

34.3.1

2 release files

34.3.0

2 release files

33.3.0

2 release files

32.3.2

2 release files

32.3.1

2 release files

32.3.0

2 release files

32.0.0

2 release files

31.1.0

2 release files

30.3.1

2 release files

30.3.0

2 release files

30.1.1

2 release files

29.0.1

2 release files

29.0.0

2 release files

28.2.1

2 release files

26.9.0

2 release files

24.2.2

2 release files

24.2.1

2 release files

24.2.0

2 release files

23.6.0

2 release files

22.6.5

2 release files

22.6.3

1 release file

22.6.2

1 release file

22.6.1

1 release file

22.6.0

1 release file

21.7.1

1 release file

21.7.0

1 release file

19.15.0

1 release file

12.1.2

1 release file

12.1.1

1 release file

12.1.0

1 release file

12.0.1

1 release file

12.0.0

1 release file

11.3.0

1 release file

11.2.0

1 release file

11.1.0

1 release file

11.0.0

1 release file

10.0.1

1 release file

10.0.0

1 release file

9.1.0

1 release file

9.0.0

1 release file

8.1.0

1 release file

8.0.3

1 release file

8.0.2

1 release file

8.0.1

1 release file

8.0.0

1 release file

7.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page