diff --git a/CHANGELOG.md b/CHANGELOG.md index 59f69a4153..e28dec83b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Basic asyncio support + +- Basic asyncio with kube config, and in_cluster_config is added. + +- Dynamic client, watch, stream, shared informer, leader election are not yet supported in asyncio. + # Breaking Change from upgrading openapi generator to v6.6.0 - Legacy dict(str, str) syntax is no longer supported in ApiClient deserializer. Only modern dict[str, str] syntax is supported. diff --git a/README.md b/README.md index 9066f7a6e2..66e16e479a 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,35 @@ for i in ret.items: print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name)) ``` +list all pods using asyncio: + +```python +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()) +``` + watch on namespace object: ```python diff --git a/scripts/release.sh b/scripts/release.sh index 6a9428fcb4..02e4eca7f0 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -222,9 +222,15 @@ if [[ -n "$(git diff kubernetes/client/api/custom_objects_api.py)" ]]; then git add kubernetes/client/api/custom_objects_api.py git commit -m "generated client change for custom_objects" fi + +# Re-generate the asyncio client +scripts/update-client-asyncio.sh + # Check if there is any API change, then commit git add kubernetes/docs kubernetes/client/api/ kubernetes/client/models/ kubernetes/swagger.json.unprocessed scripts/swagger.json +git add kubernetes_asyncio/docs kubernetes_asyncio/client/api/ kubernetes_asyncio/client/models/ kubernetes_asyncio/swagger.json.unprocessed git diff-index --quiet --cached HEAD || git commit -m "generated API change" + # Commit everything else git add . git commit -m "generated client change"