kubernetes-python-client
Documentation
Release
Kubernetes
Nov 01, 2017
Contents
1 Readme
2 Installation
3 Usage
4 kubernetes
4.1
kubernetes package .
.
.
.
.
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5 Contributing
6 Indices and tables
Python Module Index
3
7
9
11
11
639
641
643
i
ii
kubernetes-python-client Documentation, Release
Contents:
Contents
1
kubernetes-python-client Documentation, Release
2
Contents
CHAPTER 1
Readme
[![PyPI
supported
Status](https://travis-ci.org/kubernetes-incubator/client-python.svg?branch=master){]}(https://travis-ci.
version](https://badge.fury.io/py/kubernetes.svg){]}(https:
[![codecov](https://codecov.io/gh/kubernetes-incubator/client-python/branch/master/
only”)
versions](https://img.shields.io/pypi/pyversions/kubernetes.svg){]}(https://pypi.python.org/
[![Client Capabilities](https://img.shields.io/badge/Kubernetes%20client-Silver-blue.svg?style=
Support
# Kubernetes Python Client
[![Build
org/kubernetes-incubator/client-python)
//badge.fury.io/py/kubernetes)
graph/badge.svg){]}(https://codecov.io/gh/kubernetes-incubator/client-python
[![pypi
pypi/kubernetes)
flat&colorB=C0C0C0&colorA=306CE8){]}(http://bit.ly/kubernetes-client-capabilities-badge)
Level](https://img.shields.io/badge/kubernetes%20client-beta-green.svg?style=flat&colorA=306CE8){]}(http:
//bit.ly/kubernetes-client-support-badge)
Python client for the [kubernetes](http://kubernetes.io/) API.
## Installation
From source:
“Non-generated
packages
[![Client
` git clone --recursive https://github.com/kubernetes-incubator/client-python.
git cd client-python python setup.py install `
From [PyPi](https://pypi.python.org/pypi/kubernetes/) directly:
` pip install kubernetes `
## Example
list all pods:
‘‘‘python from kubernetes import client, config
# Configs can be set in Configuration class directly or using helper utility config.load_kube_config()
v1 = client.CoreV1Api() print(“Listing pods with their IPs:”) ret = v1.list_pod_for_all_namespaces(watch=False) for
i in ret.items:
print(“%st%st%s” % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
3
kubernetes-python-client Documentation, Release
‘‘‘
watch on namespace object:
‘‘‘python from kubernetes import client, config, watch
# Configs can be set in Configuration class directly or using helper utility config.load_kube_config()
v1 = client.CoreV1Api() count = 10 w = watch.Watch()
quest_timeout=60):
for event
in w.stream(v1.list_namespace, _re-
print(“Event: %s %s” % (event[’type’], event[’object’].metadata.name)) count -= 1 if not count:
w.stop()
print(“Ended.”) ‘‘‘
More examples can be found in [examples](examples/) folder. To run examples, run this command:
`shell python -m examples.example1 `
and Models’
(replace example1 with the example base filename)
## Documentation
All APIs
file](kubernetes/README.md)
## Compatibility
client-python follows [semver](http://semver.org/), so until the major version of client-python gets increased, your
code will continue to work with explicitly supported versions of Kubernetes clusters.
#### Compatibility matrix
client’s README
documentation
[Generated
can
be
found
at
the
| Kubernetes 1.4 | Kubernetes 1.5 | Kubernetes 1.6 | Kubernetes 1.7 | Kubernetes 1.8 |
|——————–|—————-|—————-|—————-|—————-|—————-| | client-python 1.0 | + | | - | -
|- | | client-python 2.0 | + | + | | - |- | | client-python 3.0 | + | + | + | | | | client-python HEAD | + | + | + | + | |
Key:
• Exactly the same features / API objects in both client-python and the Kubernetes version.
• + client-python has features or api objects that may not be present in the Kubernetes cluster, but everything they
have in common will work.
• - The Kubernetes cluster has features the client-python library can’t use (additional API objects, etc).
See the [CHANGELOG](./CHANGELOG.md) for a detailed description of changes between client-python versions.
Client version | Canonical source for OpenAPI spec | Maintenance status |
| | 1.0.x | Kubernetes main repo, 1.5 branch | | | 2.0 Alpha/Beta | Kubernetes main repo, 1.6 branch |
|—————-|————————————–|——————————-| | 1.0 Alpha/Beta | Kubernetes main repo, 1.5
branch |
| | 2.0.x
| Kubernetes main repo, 1.6 branch | | | 3.0 Alpha/Beta | Kubernetes main repo, 1.7 branch |
| | 3.0 | Kubernetes main
repo, 1.7 branch | | | 4.0 Alpha/Beta | Kubernetes main repo, 1.8 branch |
Key:
|
4
Chapter 1. Readme