Backend - Kubernetes

class conu.backend.k8s.backend.K8sBackend(api_key=None, logging_level=20, logging_kwargs=None, cleanup=None)

Bases: Backend

ContainerClass

alias of Container

ImageClass

alias of Image

__init__(api_key=None, logging_level=20, logging_kwargs=None, cleanup=None)

This method serves as a configuration interface for conu.

Parameters:
  • api_key – str, Bearer API token

  • logging_level – int, control logger verbosity: see logging.{DEBUG,INFO,ERROR}

  • logging_kwargs – dict, additional keyword arguments for logger set up, for more info see docstring of set_logging function

  • cleanup – list, list of k8s cleanup policy values, examples: - [CleanupPolicy.EVERYTHING] - [CleanupPolicy.PODS, CleanupPolicy.SERVICES] - [CleanupPolicy.NOTHING]

cleanup_containers()

Remove containers associated with this backend instance

Returns:

None

cleanup_deployments()

Delete all deployments created in namespaces associated with this backend :return: None

cleanup_images()

Remove images associated with this backend instance

Returns:

None

cleanup_namespaces()

Delete all namespaces created by this backend :return: None

cleanup_pods()

Delete all pods created in namespaces associated with this backend :return: None

cleanup_services()

Delete all services created in namespaces associated with this backend :return: None

cleanup_volumes()

Remove volumes associated with this backend instance

Returns:

None

create_namespace()

Create namespace with random name :return: name of new created namespace

delete_namespace(name)

Delete namespace with specific name :param name: str, namespace to delete :return: None

list_containers()

list all available containers for this backend

Returns:

collection of instances of conu.apidefs.container.Container

list_deployments(namespace=None)

List all available deployments.

Parameters:

namespace – str, if not specified list deployments for all namespaces

Returns:

collection of instances of conu.backend.k8s.deployment.Deployment

list_images()

list all available images for this backend

Returns:

collection of instances of conu.apidefs.image.Image

list_pods(namespace=None)

List all available pods.

Parameters:

namespace – str, if not specified list pods for all namespaces

Returns:

collection of instances of conu.backend.k8s.pod.Pod

list_services(namespace=None)

List all available services.

Parameters:

namespace – str, if not specified list services for all namespaces

Returns:

collection of instances of conu.backend.k8s.service.Service

class conu.backend.k8s.backend.K8sCleanupPolicy(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)

This Enum defines the policy for cleanup.

  • NOTHING - clean nothing

  • EVERYTHING - delete just objects in all namespaces

    associated with this backend - (pods, service, deployments)

  • NAMESPACES - delete all namespaces associated with this backend and

    objects in these namespaces (pods, service, deployments)

  • PODS - delete all pods in namespaces associated with this backend

  • SERVICES - delete all services in namespaces associated with this backend

  • DEPLOYMENTS - delete all deployments in namespaces associated with this backend