我目前已经在K8s集群中安装并运行了metric服务器。在
利用kubernetes python库,我可以请求获取pod度量:
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))
在响应中,将列出每个吊舱的所有容器及其cpu和内存使用情况:
^{pr2}$现在我的问题是如何获得吊舱本身而不是容器的这些指标?如果可能的话,我不想从每个容器中总结度量。有什么方法可以用metrics服务器做到这一点吗?在
根据official repository可以查询kubeletstats端点:
它将返回完整吊舱的统计信息。如果要查看吊舱/容器本身的指标,请键入:
^{pr2}$让我们来看一个例子:
这些请求将起作用:
你也可以找这个article。我希望这对你有帮助。在
相关问题 更多 >
编程相关推荐