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.

  • body (dict[str, Any]) – Custom object to create.

  • timeout (Timeout) – Timeout on operation.

  • replace (bool, default: False) – If True 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:
Return type:

None

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:
Return type:

None

async list(namespace, timeout)

List the custom objects in a namespace.

Parameters:
  • namespace (str) – Namespace in which to list custom objects.

  • timeout (Timeout) – Timeout on operation.

Returns:

List of custom objects found.

Return type:

list of dict

Raises:
async read(name, namespace, timeout)

Read a custom object.

Parameters:
  • name (str) – Name of the custom object.

  • namespace (str) – Namespace of the custom object.

  • timeout (Timeout) – Timeout on operation.

Returns:

Custom object, or None if it does not exist.

Return type:

dict or None

Raises:
async wait_for_deletion(name, namespace, timeout)

Wait for a custom object deletion to complete.

Parameters:
  • name (str) – Name of the custom object.

  • namespace (str) – Namespace of the custom object.

  • timeout (Timeout) – How long to wait for the object to be deleted.

Raises:
Return type:

None