piceli.k8s.templates.auxiliary.resource_request#
Module Contents#
Classes#
Represents Kubernetes resources, facilitating arithmetic operations and validation. |
|
Resources of a kubernetes container |
|
Resources of a kubernetes pod |
|
Resources of a kubernetes node |
|
Resources of a kubernetes cluster |
API#
- class piceli.k8s.templates.auxiliary.resource_request.Resources[source]#
Represents Kubernetes resources, facilitating arithmetic operations and validation.
Attributes: :param Optional[str] memory: The amount of memory allocated for the resource. Specified in Kubernetes quantity string format (e.g., ‘200Mi’, ‘1Gi’). :param Optional[str] cpu: The amount of CPU allocated for the resource. Specified in Kubernetes quantity string format (e.g., ‘100m’ for 100 millicpu). :param Optional[str] ephemeral_storage: The amount of ephemeral storage allocated for the resource. Specified in Kubernetes quantity string format.
The class supports creating
Resourcesobjects from dictionaries, converting between string and numerical representations, and performing arithmetic operations on resource quantities. These capabilities are essential for managing resource allocations in Kubernetes deployments.- classmethod from_dict(resources: dict[str, str]) piceli.k8s.templates.auxiliary.resource_request.Resources[source]#
Creates a
Resourcesobject from a dictionary of string quantities.
- classmethod from_quantity_dict(resources: dict[str, int | float | None]) piceli.k8s.templates.auxiliary.resource_request.Resources[source]#
Creates a
Resourcesobject from a dictionary of quantities, converting them to string format.
- to_quantity_dict() dict[str, Optional[float]][source]#
creates a dict from a Resources object containing the quantity in k
- get_quantity(resource: str) int | float[source]#
gets the quantity in k from a resource (cpu can be a float)
- static bytes_to_str(num: float, resource: str) str[source]#
gets a human readable string representation
- __add__(other: piceli.k8s.templates.auxiliary.resource_request.Resources) piceli.k8s.templates.auxiliary.resource_request.Resources[source]#
- __sub__(other: piceli.k8s.templates.auxiliary.resource_request.Resources) piceli.k8s.templates.auxiliary.resource_request.Resources[source]#
- __mul__(other: float | int) piceli.k8s.templates.auxiliary.resource_request.Resources[source]#
- __truediv__(other: Union[float, int, piceli.k8s.templates.auxiliary.resource_request.Resources]) Union[piceli.k8s.templates.auxiliary.resource_request.Resources, float][source]#
- any_lower(other: piceli.k8s.templates.auxiliary.resource_request.Resources) bool[source]#
if any of the values is lower it will return True
- any_greater(other: piceli.k8s.templates.auxiliary.resource_request.Resources) bool[source]#
if any of the values is greater it will return True
- class piceli.k8s.templates.auxiliary.resource_request.ContainerResourcesData[source]#
Resources of a kubernetes container
- requested_resources: piceli.k8s.templates.auxiliary.resource_request.Resources#
None
- used_resources: piceli.k8s.templates.auxiliary.resource_request.Resources#
None
- class piceli.k8s.templates.auxiliary.resource_request.ResourcesData[source]#
Resources of a kubernetes pod
- last_update: Optional[datetime.datetime]#
None
- containers: dict[str, piceli.k8s.templates.auxiliary.resource_request.ContainerResourcesData]#
‘field(…)’
- class piceli.k8s.templates.auxiliary.resource_request.NodeResources[source]#
Resources of a kubernetes node
- allocatable: piceli.k8s.templates.auxiliary.resource_request.Resources#
None
- capacity: piceli.k8s.templates.auxiliary.resource_request.Resources#
None
- classmethod from_node_status(node: kubernetes.client.V1Node) piceli.k8s.templates.auxiliary.resource_request.NodeResources[source]#
creates a ClusterResources object from a list of kubernetes nodes
- class piceli.k8s.templates.auxiliary.resource_request.ClusterResources[source]#
Resources of a kubernetes cluster
- total_allocatable: piceli.k8s.templates.auxiliary.resource_request.Resources#
None
- total_capacity: piceli.k8s.templates.auxiliary.resource_request.Resources#
None
- pods_map: dict[str, piceli.k8s.templates.auxiliary.resource_request.ResourcesData]#
None
- property pods: list[piceli.k8s.templates.auxiliary.resource_request.ResourcesData]#
returns a list of pods
- get_pod(pod_name: str) piceli.k8s.templates.auxiliary.resource_request.ResourcesData | None[source]#
returns a pod by name