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.
istio = CustomObject("my-istio", "my-namespace", plural="istios", api_version="istio.banzaicloud.io/v1beta1")
istio["spec"] = {"version": "1.1.0", "mtls": True}
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:
print(istio["status"])
istio.reload()
istio.auto_reload = True
while istio["status"]["Status"] == "Reconciling": time.sleep(5)
print("Our status is:", istio["status"]["Status"])
After doing all its work, the Istio
object might need to be deleted:
istio.delete()