overscaler package¶
Submodules¶
overscaler.overcli module¶
overscaler.overprint module¶
-
overscaler.overprint.
print_cluster_info
(autoscale, current_nodes, max_nodes, min_nodes, metrics)[source]¶ Prints Cluster information by console.
- Parameters:
- autoscale: bool
- True if the node autoscale is active.
- current_nodes: int
- Number of current nodes.
- max_nodes: int
- Maximum number of allowed nodes.
- min_nodes: int
- Minimum number of allowed nodes.
- metrics: array list
- List of cluster metrics to monitor.
-
overscaler.overprint.
print_node_status
(node_status)[source]¶ Prints Node status by console.
- Parameters:
- node_status: dict
- Dictionary with all the information about the status of each node.
overscaler.overtools module¶
-
overscaler.overtools.
actions
(api, namespace, pod_status, statefulset_labels, max_nodes)[source]¶ Decision making based on pods status and stateful set rules.
- Parameters:
- api: pykube.http.HTTPClient
- Http client for requests to Kubernetes Api.
- namespace: str
- Project namespace.
- pod_status: dict
- Dictionary with status pod information.
- statefulset_lables: dict
- Dict with metrics and rules of each stateful set.
- max_nodes: int
- Maximum number of allowed nodes.
-
overscaler.overtools.
check_rule
(rule, typ)[source]¶ Checks the rules are well written.
Format rule: “metric_greater|lower_limit_scale|reduce”- Parameters:
- rule: str
- Rule to check.
- type: str
- Rule type, can be for node or pod
- Returns:
- check: bool
- True if the rule has correct format.
-
overscaler.overtools.
get_cluster_labels
(cluster_info)[source]¶ Gets cluster information.
Returns information about the number of nodes and their limits, node autoscale function and labels.
- Parameters:
- cluster_info: dict
- Dictionary with all cluster information.
- Returns:
- autoscale: bool
- True if node autoscale is active.
- max_nodes: int
- Maximum number of allowed nodes.
- min_nodes: int
- Minimum number of allowed nodes.
- metrics: list
- List of cluster metrics to monitor.
-
overscaler.overtools.
get_mean
(metric)[source]¶ Calculates the arithmetic mean of a metric.
- Parameters:
- metric: dict
- Dictionary with status metrics.
- Returns:
- mean: float
- Arithmetic mean.
-
overscaler.overtools.
get_metrics
(labels, typ)[source]¶ Get metrics from a dictionary of labels.
- Parameters:
- labels: dict
- Dictionary with all metrics.
- typ: str
- Metrics type, “pod” or “cluster”.
- Returns:
- metrics: str lst
- List with metrics to monitor.
-
overscaler.overtools.
get_node_status
(metrics)[source]¶ Gets Node status.
Returns information about state of all nodes.
- Parameters:
- metrics: str list
- List of metrics to monitor.
- Returns:
- node_status: dict
- Dictionary with all the information.
- Returned dict format:
- {
- node_name1:{
- metric-1: float,
- Metric-1 value.
- metric-2: float,
- Metric-2 value.
… }
node_name2:{ … }
… }
-
overscaler.overtools.
get_num_nodes
()[source]¶ Returns number of active nodes.
- Returns:
- num_nodes: int
- Number of current nodes.
-
overscaler.overtools.
get_pod_status
(api, namespace, statefulset_labels, memory_allocatable, cpu_allocatable)[source]¶ Gets Pod status.
Returns information about state of all stateful set pods.
- Parameters:
- api: pykube.http.HTTPClient
- Http client for requests to Kubernetes Api.
- namespace: str
- Project namespace.
- statefulset_lables: dict
- Dict with metrics for each stateful set.
- memory_allocatable: int
- Maximum memory allowed per node, expressed in bytes.
- cpu_allocatable: int
- Maximum memory allowed per node, expressed in minicores.
- Returns:
- pod_status: dict
- Dictionary with all the information.
Returned dict format:
- {
- node_name1:{
- pod-name1:{
- metric-1: float,
- Metric-1 value.
- metric-2: float,
- Metric-2 value.
… }
- pod-name2:{
- … }
}
- node_name2:{
- … }
… }
-
overscaler.overtools.
get_rules
(labels, name)[source]¶ Get rules from a dictionary of labels.
- Parameters:
- labels: dict
- Dictionary with all rules.
- name: str
- Stateful Set name.
- Returns:
- rules: str list
- List with all rules to apply.
-
overscaler.overtools.
get_statefulset_labels
(statefulset_info)[source]¶ Gets Stateful Set information. Returns information about labels, metrics and rules.
- Parameters:
- statefulset_info: dict
- Dictionary with all Stateful Set information.
- Returns:
- statefulset_labels: dict
- Dictionary with only the information needed for the overscaler.
- Returned dict format:
- {
- statefulset_name1:{
- overscaler: bool,
- Is overscaler active?
- current-count:int,
- Autoscale pause counter.
- autoscaler-count: int number,
- Number of waiting cycles after rescalling.
- max-replicas: int,
- Maximum number of replicas.
- min-replicas: int,
- Minimum number of replicas.
- metrics: [str, str…],
- List with all metrics to monitor.
- rules: [str,str…]
- List with all rules for this Stateful Set.
… }
- statefulset_name2:{
- … }
… }
-
overscaler.overtools.
rescale
(api, namespace, statefulset_name, action, max_nodes)[source]¶ Sets a new number of replicas for a given stateful set.
- Parameters:
- api: pykube.http.HTTPClient
- Http client for requests to Kubernetes Api.
- namespace: str
- Project namespace.
- statefulset_name: dict
- Name of the statefulset to be rescaled.
- action: str
- Action to be realized. Can be “scale” o “reduce”, one pods more or one pod less, respectively.
- max_nodes: dict
- Maximum number of allowed nodes.
-
overscaler.overtools.
start_proxy
()[source]¶ Starts local proxy to Kubernetes cluster, host: 127.0.0.1:8001
-
overscaler.overtools.
update_current_count
(api, namespace, statefulsets_labels)[source]¶ Updates the “current-count” label of all Stateful sets.
If its value is 0, this stateful set is ready to be scaled if is necessary.
- Parameters:
- api: pykube.http.HTTPClient
- Http client for requests to Kubernetes Api.
- namespace: str
- Project namespace.
- statefulset_lables: dict
- Dict with metrics and rules of each stateful set.