tiny-kubernetes
tiny-kubernetes provides a thin wrapper on top of requests to make it
easier to work with Kubernetes APIs.
Features
- Automatic authentication (
$KUBECONFIG) - Simplified response traversal (
never['do']['this']['again']) thanks to DotMap - Sane exceptions
- No crazy complex client-side APIs to deal with
Why?
The official kubernetes package is, uh, complex. While it does support all the advanced features the Kubernetes API offers (like WebSocket streaming) it is often non-trivial to work with. tiny-kubernetes aims to provide most of the same functionality with minimal overhead.
Installation
pip install tiny-kubernetes
Usage
from tiny_kubernetes import KubernetesAPIClient
client = KubernetesAPIClient()
client.load_auto_config()
pods = client.get('/api/v1/namespaces/{}/pods', 'default')
for pod in pods['items']:
print pod.metadata.name
Notice that you can access (almost) all parts of the Kubernetes API response
using dot accessors (courtesy of DotMap). As .items() is a reserved name
in dictionaries, it needs to be accessed more traditionally, but most other
member names can use the shortened syntax.
The endpoint is formatted using str.format with the remaining positional
arguments. All keyword arguments are passed through to requests's
Session.request, so you can include a body with json={...} or URL
parameters with params={...}.
A special json_patch method exists to help perform patches. It works around
a few potential requests bugs automatically. For example, it can be used to
append labels to a resource:
client.json_patch([{
'op': 'add',
'path': '/metadata/labels/foo',
'value': 'bar'
}], '/api/v1/namespaces/{}/pods/{}', 'default', 'some-pod')
Notes
- Temporary files may be created if using a local
$KUBECONFIGwith base64-encoded certificates. Due to limitations in python's SSL library these must be decoded and written to the filesystem to be used. They should be cleaned up when the interpreter exits.
Metadata
Release files for tiny-kubernetes 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tiny-kubernetes-1.1.1.tar.gz | 20.0 kB | Without provenance | Details for tiny-kubernetes-1.1.1.tar.gz |
Release files / tiny-kubernetes-1.1.1.tar.gz
| Download URL | tiny-kubernetes-1.1.1.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
669bc5d827e0baceca9707ba22a7de03ff6abe25c8554e10fd1e0ec51dcb273e
|
|
BLAKE2b-256 checksum How to use checksums |
10920689893536a40ab6414cae0c5f9d784d941ae6ccfba4c61f78a6068150ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.29.0 CPython/3.6.7
|
Security for tiny-kubernetes 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.