Kubernetes Asynchronous Python Client
Maintained. Last release 6 months ago, commits in 6 of the last 26 weeks.
pip install kubernetes-asyncioKubernetes Python Client
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())