K8S Pod recommendations

Pod recommendations

class nops_sdk.k8s.pod_recommendations.K8SPeriodicity(value)

Bases: enum.Enum

Denotes the choices of periodicity for K8S recommendations.

SEVEN_DAYS = 7
THIRTY_DAYS = 30
TWENTY_FOUR_HOURS = 1
class nops_sdk.k8s.pod_recommendations.K8SRecommendations(cluster_id)

Bases: object

Get K8S pod request and limit configuration recommendations.

Parameters

cluster_id (str) – id of the concerned cluster

Return type

None

Example

>>> from nops_sdk.k8s.pod_recommendations import K8SRecommendations
>>> recommendations = K8SRecommendations(cluster_id="my_clust_id")
>>> recommendations.overview(period=K8SPeriodicity.TWENTY_FOUR_HOURS)
[
    {
        "base_name": "pod_name1",
        "recommendations": 1
    },
    {
        "base_name": "pod_name2",
        "recommendations": 1
    }
    ...
]
>>> recommedantions.by_pod(base_name="pod_name2", period=K8SPeriodicity.TWENTY_FOUR_HOURS)
[{
    'name': 'pod_name2',
    'cost': 4.725176576592933,
    'ram_usage': 140937142.27470765,
    'cpu_usage': 0.0022271234666475024,
    'ram_request': 1000000000.0,
    'cpu_request': None,
    'ram_limit': 1000000000.0,
    'cpu_limit': None,
    'container': 'pod_name2',
    'recommended_ram_request': 105702856.70603073,
    'recommended_ram_limit': 158554285.0590461,
    'recommended_cpu_request': 0.0022271234666475024,
    'recommended_cpu_limit': 0.0033406851999712535,
    'savings': 2.1128559570033185
}]
__init__(cluster_id)
Parameters

cluster_id (str) –

Return type

None

by_pod(base_name, period)

Get recommendations for a specific pod.

Parameters
overview(period)

Get an overview of recommendations containing a count of recommendations per pod.

Parameters

period (nops_sdk.k8s.pod_recommendations.K8SPeriodicity) – concerned time period

Returns

list of pod names with a count of recommendations associated with them

Return type

dict