Skip to main content

kubelib

Python library to simplify kubernetes scripting. Minimal test coverage.

Full Documentation Here

TODO: The current plan is to rebuild this around <https://github.com/kubernetes-incubator/client-python>.

Quickstart

Import Kubelib and config:

import kubelib
kube = kubelib.KubeConfig(context='dev-seb', namespace='myspace')

List all namespaces:

for ns in kubelib.Namespace(kube).get_list():
        print(ns.metadata.name)

List all resource controllers:

for ns in kubelib.ReplicationController(kube).get_list():
    print(ns.metadata.name)

(you get the idea)

Get a specific pod:

pod = kubelib.Pod(kube).get(podname)
print(pod.toJSON())

Upgrading Kubernetes

Upgrade kubernetes based on a directory of yaml files:

import kubelib
kube = kubelib.KubeConfig(context='dev-seb', namespace='myspace')
kube.apply_path("./kubernetes", recursive=True)

This will look at every yaml file and act based on the “Kind” field. Deployments are replaced, replication controllers are deleted and re-created. Other “Kind” resources are created if a resource with that “Kind” and “Name” is not already present.

Command Line Utilities

This package provides a few command line utilities, the most helpful (to me) is see_limits which displays the resource limits for all pods and namespaces within a context.


Initial package setup borrowed from https://github.com/kennethreitz/samplemod

A reasonable approach to getting sphinx output into github pages from https://daler.github.io/sphinxdoc-test/includeme.html

Release files for kubelib 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kubelib 0.3.0
File Size Uploaded
kubelib-0.3.0.tar.gz 27.6 kB Details

Release files / kubelib-0.3.0.tar.gz

Download URL kubelib-0.3.0.tar.gz
Size 27.6 kB
Tags Source
SHA-256 checksum
How to use checksums
554577fc711f85b970416d154ed9db261273c206ba183c60af0dfd3f653fb814
BLAKE2b-256 checksum
How to use checksums
96d5c1a04d8b4d834202037cfa2f6ac2c59937f4c68e86890d676158dfd004e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file

0.2.54

1 release file

0.2.50

1 release file

0.2.22

1 release file

0.2.20

1 release file

0.2.19

1 release file

0.2.18

1 release file

0.2.17

1 release file

0.2.16

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page