Skip to main content

KubeObject

A simple to use wrapping on top of Kubernetes custom resources with object oriented semantics.

KubeObject allows you to use Kubernetes Custom Objects in an object oriented way. It works by defining an object, by instantiating it with a name and namespace and then "bounding" this object to a Kubernetes object by creating it, or loading it, if it already exists.

Quick Start

In the following example we create an "Istio" object, which will manage one of the Custom Objects defined by the Istio operator. A simple lifecycle is explained below.

# Builds the object, but it is "unbound", this is, it is not
# referring to an actual object in Kubernetes.
istio = CustomObject("my-istio", "my-namespace", plural="istios", api_version="istio.banzaicloud.io/v1beta1")

# Let's pass the simplest spec we can
istio["spec"] = {"version": "1.1.0", "mtls": True}

# And now create it; after creation the object is "bound"
istio.create()

Updating the object's Spec and checking the object's Status is one of our goals as well, like in the following example:

# The Istio operator should have started working on deploying
# this new Custom Resource. Let's get the status of the object
print(istio["status"])

# This is empty, because since calling `create()` we have not
# updated from the actual object in Kubernetes. Let's get an
# up-to-date object.
istio.reload()

# I want to avoid calling `reload()` everytime I need a new
# version
istio.auto_reload = True

# Now we'll wait until the object has reached a given status:
while istio["status"]["Status"] == "Reconciling": time.sleep(5)

# Check the Status after "Reconciling"
print("Our status is:", istio["status"]["Status"])

After doing all its work, the Istio object might need to be deleted:

istio.delete()

Metadata

Release files for kubeobject 0.2.1

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

Source distribution (sdist)

Source distribution for kubeobject 0.2.1
File Size Uploaded
kubeobject-0.2.1.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kubeobject 0.2.1
File Interpreter ABI Platform
kubeobject-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 33.9 kB

Release files / kubeobject-0.2.1.tar.gz

Download URL kubeobject-0.2.1.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a807945ea36b4144bca2df4b2e91bfa4f37dcb0a19234980b5f4d7d3b8c80bda
BLAKE2b-256 checksum
How to use checksums
bdb700804659a13af0b2b95454e3ae936c91ca9af7acdd0b78eafb6a2c4c9c40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

Release files / kubeobject-0.2.1-py3-none-any.whl

Download URL kubeobject-0.2.1-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18678e2fc778dc84bd8cb279b4ac8f9563616f03149b49d76b2eb77b4499ef5d
BLAKE2b-256 checksum
How to use checksums
25e124d7b11efb282ec886bf63c029624f8c11d163e547cfac3ef0ef6afc0f6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.9

3 release files

0.1.8

3 release files

0.1.7

3 release files

0.1.6

3 release files

0.1.5

3 release files

0.1.4

3 release files

0.1.3

3 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

3 release files

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