I currently have metric server installed and running in my K8s cluster.
Utilizing the the kubernetes python lib, I am able to make this request to get pod metrics:
from kubernetes import client
api_client = client.ApiClient()
ret_metrics = api_client.call_api(
'/apis/metrics.k8s.io/v1beta1/namespaces/' + 'default' + '/pods', 'GET',
auth_settings=['BearerToken'], response_type='json', _preload_content=False)
response = ret_metrics[0].data.decode('utf-8')
print('RESP', json.loads(response))
In the response, for each pod all containers will be listed with their cpu and memory usage:
'containers': [{'name': 'elasticsearch', 'usage': {'cpu': '14122272n', 'memory': '826100Ki'}}]}
Now my question is how do i get these metrics for the pod itself and not its containers? I'd rather not have to sum up the metrics from each container if possible. Is there any way to do this with metrics-server?