Giter Site home page Giter Site logo

gridl / kubernetes_asyncio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tomplus/kubernetes_asyncio

0.0 1.0 0.0 1.8 MB

Python asynchronous client library for Kubernetes http://kubernetes.io/

License: Apache License 2.0

Python 99.84% Shell 0.16%

kubernetes_asyncio's Introduction

Kubernetes Python Client

Build Status PyPI version codecov pypi supported versions

Asynchronous (AsyncIO) client library for the Kubernetes API.

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

Installation

From PyPi directly:

pip install kubernetes_asyncio

Example

To list all pods:

import asyncio
from kubernetes_asyncio import client, config


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()

    v1 = client.CoreV1Api()
    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__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
    loop.close()

More complicated examples, like asynchronous multiple watch or tail logs from pods, you can find in examples/ folder.

Comparison with official synchronous library

This library is generated in the same way as the official Kubernetes Python Library. It uses swagger-codegen and the same concepts like streaming, watching or reading configuration. Because of an early stage of this library some differences still exist:

synchronous library kubernetes-client/python this libray
authentication method gcp-token, user-token, oid-token, user-password, in-cluster gcp-token (only via gcloud command), user-token, user-password, in-cluster
refesh token no yes, optional
python 2.7 3.4 3.5 3.6 3.5 3.6
streaming data via websocket from PODs bidirectional read-only is already implemented

Development

Install the development packages:

pip install -r requirements.txt
pip install -r test-requirements.txt

You can run the style checks and tests with

flake8 && isort -c
nosetests

kubernetes_asyncio's People

Contributors

evemorgen avatar olitheolix avatar tomplus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.