Welcome to AIOKUBERNETES¶
Asynchronous Kubernetes Client for asyncio and Python 3.6+.
Key Features¶
- Based on aiohttp.
- Stream output when executing commands in Pods.
- Auto-generated via Swagger and Kubernetes Python client generator.
Library Installation¶
$ pip install aiokubernetes
Getting Started¶
"""Print the name of all pods in the cluster."""
import asyncio
import aiokubernetes as k8s
async def main():
# Create a client instance and load the credentials from ~/.kube/kubeconfig
api_client = k8s.config.new_client_from_config()
# Ask for all Pods.
v1 = k8s.api.CoreV1Api(api_client)
ret = await v1.list_pod_for_all_namespaces()
# Ensure the API call to Kubernetes succeeded.
assert ret.http.status == 200
# Print the pod names.
for i in ret.obj.items:
print(f"{i.metadata.namespace} {i.metadata.name}")
# Terminate the connection pool for a clean shutdown.
await api_client.session.close()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
More examples are available here.
Source code¶
The project is hosted on GitHub
Please feel free to file an issue on the bug tracker if you have found a bug or have some suggestion in order to improve the library.
The library uses Travis for Continuous Integration.
License¶
The aiokubernetes
package is Apache 2 licensed and freely available.