CustomStorage¶
- class controller.storage.kubernetes.custom.CustomStorage(*, api_client, group, version, plural, kind, logger)¶
Bases:
object
Storage layer for Kubernetes custom objects.
Normally, this class should be subclassed to specialize it for a specific custom object type, which provides a slightly nicer API, but it can be used as-is if desired.
- Parameters:
api_client (
ApiClient
) – Kubernetes API client.group (
str
) – API group for the custom objects to handle.version (
str
) – API version for the custom objects to handle.plural (
str
) – API plural under which those custom objects are managed.kind (
str
) – Name of the custom object kind, used for error reporting.logger (
BoundLogger
) – Logger to use.
Methods Summary
create
(namespace, body, timeout, *[, ...])Create a new custom object.
delete
(name, namespace, timeout, *[, wait, ...])Delete a custom object.
list
(namespace, timeout)List the custom objects in a namespace.
read
(name, namespace, timeout)Read a custom object.
wait_for_deletion
(name, namespace, timeout)Wait for a custom object deletion to complete.
Methods Documentation
- async create(namespace, body, timeout, *, replace=False, propagation_policy=None)¶
Create a new custom object.
- Parameters:
namespace (
str
) – Namespace of the object.timeout (
Timeout
) – Timeout on operation.replace (
bool
, default:False
) – IfTrue
and an object of that name already exists in that namespace, delete the existing object and then try again.propagation_policy (
PropagationPolicy
|None
, default:None
) – Propagation policy for the object deletion when deleting a conflicting object.
- Raises:
ControllerTimeoutError – Raised if the timeout expired waiting for deletion.
KubernetesError – Raised for exceptions from the Kubernetes API server.
TimeoutError – Raised if the timeout expired.
- Return type:
- async delete(name, namespace, timeout, *, wait=False, propagation_policy=None)¶
Delete a custom object.
If the object does not exist, this is silently treated as success.
- Parameters:
name (
str
) – Name of the object.namespace (
str
) – Namespace of the object.timeout (
Timeout
) – Timeout on operation.wait (
bool
, default:False
) – Whether to wait for the custom object to be deleted.propagation_policy (
PropagationPolicy
|None
, default:None
) – Propagation policy for the object deletion.
- Raises:
ControllerTimeoutError – Raised if the timeout expired waiting for deletion.
KubernetesError – Raised for exceptions from the Kubernetes API server.
TimeoutError – Raised if the timeout expired.
- Return type:
- async list(namespace, timeout)¶
List the custom objects in a namespace.
- Parameters:
- Returns:
List of custom objects found.
- Return type:
- Raises:
KubernetesError – Raised for exceptions from the Kubernetes API server.
TimeoutError – Raised if the timeout expired.
- async read(name, namespace, timeout)¶
Read a custom object.
- Parameters:
- Returns:
Custom object, or
None
if it does not exist.- Return type:
dict or None
- Raises:
KubernetesError – Raised for exceptions from the Kubernetes API server.
TimeoutError – Raised if the timeout expired.
- async wait_for_deletion(name, namespace, timeout)¶
Wait for a custom object deletion to complete.
- Parameters:
- Raises:
ControllerTimeoutError – Raised if the timeout expired.
KubernetesError – Raised for exceptions from the Kubernetes API server.
- Return type: