This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Opinionated Python interface for the Kubernetes API

This package provides a Pythonic interface to use the Kubernetes API from within Python code. It is hand-crafted and opinionated in an attempt to hide the edge cases and cumbersome parts of the raw API which would be exposed by a client using the swagger definitions.

This package is far from finished, the current major features are:

  • Major resources wrapped:
    • Nodes
    • Namespaces
    • Pods
    • ReplicaSets/ReplicationControllers
    • Services
    • Secrets
  • Good labelling support
  • Both blocking and non-blocking support for the WATCH API.
  • Query, create and delete resources.
  • Low-level API to use Kubernetes API more directly.
  • Write tests without needing a real cluster

We are working on these features:

  • Modifying ReplicaSets: i.e. changing number of replicas, changing selectors.
  • Modifying resources in general.
  • Creating new resource items.
  • Deleting resource items.

Installation

pip install kube

Usage

To use the API one has to authenticate to the Kubernetes apiserver. Currently only the recommended approach of using kubectl in proxy mode is supported. Simply run kubectl proxy on the localhost and the connection will work. When running in a cluster itself this can be easily achieved by running the kubectl proxy in another container in the same pod.

The central object to work with the Kubernetes cluster is the Cluster object:

import kube

cluster = kube.Cluster()
rs = cluster.replicasets.fetch('proxy', namespace='default')
pods = cluster.pods.filter(labels=rs.meta.labels,
                           filter={'metadata.namespace': 'default'})
for pod in pods:
   assert pod.phase is pod.PodPhase.Running

Documentation

The kube library is fully documented at http://python-kube.readthedocs.io.

Contributing

The project is still in it’s early stages, feel free to submit suggestions, issues or pull requests to the project. https://bitbucket.org/cobeio/kube All feedback is welcome.

Development Dependencies

When developing kube you will need some extra dependencies:

  • pytest
  • pytest-cov
  • pylint
  • invoke

Testing Kube

The tests can be run in two ways: Using a stubbed-out API server (default), or against a real Kubernetes cluster. The former runs very fast and will not mess around with a real cluster. The latter is a bit slower but can be used to verify that the code behaves correctly against a real Kubernetes cluster. To reiterate, by default the tests will use the stubbed-out apiserver. To execute the tests against a real cluster, invoke them with py.test --verify <kubectl-context>. There is no need to run a kubectl proxy, this is done automatically. The tests will try not to break your cluster or leave any artefacts around after the test run, however we’d recommend that <kubectl-context> refers to a test cluster.

License

Kube is available under the LGPLv3 which allows you to use it in your own projects regardless of the license you choose, be it proprietary or open source, while keeping kube itself free software.

Release History

Release History

0.9.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.9.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.8.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
kube-0.9.1-py3-none-any.whl (36.8 kB) Copy SHA256 Checksum SHA256 py3 Wheel Sep 17, 2016
kube-0.9.1.tar.gz (55.0 kB) Copy SHA256 Checksum SHA256 Source Sep 17, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting