简体   繁体   English

如何在Kubernetes中获取pod的资源使用情况?

[英]How to get the resource usage of a pod in Kubernetes?

How can we get the real resource usage (not resource requests) of each pod on Kubernetes by command line? 我们如何通过命令行获取Kubernetes上每个pod的真实资源使用(而不是资源请求)? Heapster is deprecated. Heapster已被弃用。 Meanwhile, Metrics-server still does not support kubectl top pod . 同时,Metrics-server仍然不支持kubectl top pod

  1. Heapster - Heapster -

    I deployed Heapster using the following command 我使用以下命令部署了Heapster

     $ heapster/deploy/kube.sh start kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE kube-system calico-node-hlcbl 2/2 Running 0 39m kube-system calico-node-m8jl2 2/2 Running 0 35m kube-system coredns-78fcdf6894-bl94w 1/1 Running 0 39m kube-system coredns-78fcdf6894-fwx95 1/1 Running 0 39m kube-system etcd-ctl.kube.yarnrm-pg0.utah.cloudlab.us 1/1 Running 0 39m kube-system heapster-84c9bc48c4-qzt8x 1/1 Running 0 15s kube-system kube-apiserver-ctl.kube.yarnrm-pg0.utah.cloudlab.us 1/1 Running 0 39m kube-system kube-controller-manager-ctl.kube.yarnrm-pg0.utah.cloudlab.us 1/1 Running 0 38m kube-system kube-proxy-nj9f8 1/1 Running 0 35m kube-system kube-proxy-zvr2b 1/1 Running 0 39m kube-system kube-scheduler-ctl.kube.yarnrm-pg0.utah.cloudlab.us 1/1 Running 0 39m kube-system monitoring-grafana-555545f477-jldmz 1/1 Running 0 15s kube-system monitoring-influxdb-848b9b66f6-k2k4f 1/1 Running 0 15s 

    When I used kubectl top , I encountered the following errors. 当我使用kubectl top ,我遇到了以下错误。

     $ kubectl top pods Error from server (ServiceUnavailable): the server is currently unable to handle the request (get services http:heapster:) $ kubectl top nodes Error from server (ServiceUnavailable): the server is currently unable to handle the request (get services http:heapster:) 
  2. metrics-server: 度量服务器:

    metrics-server has not supported kubectl top Resource Metrics API metrics-server不支持kubectl top 资源指标API

If anyone already solved the same problem, please help me. 如果有人已经解决了同样的问题,请帮助我。 Thanks. 谢谢。

Error from server (ServiceUnavailable): the server is currently unable to handle the request (get services http:heapster:) 服务器出错(ServiceUnavailable):服务器当前无法处理请求(获取服务http:heapster :)

It sounds like the heapster deployment just forgot to install the Service for heapster ; 听起来像是heapster部署只是忘了为heapster安装Service ; I would expect this would get you past that error, but unknown whether it would actually cause kubectl top pods to start to work: 我希望这会让你过去那个错误,但不知道它是否真的会导致kubectl top pods开始工作:

kubectl create -f /dev/stdin <<SVC
apiVersion: v1
kind: Service
metadata:
  name: heapster
  namespace: kube-system
spec:
  selector:
    whatever-label: is-on-heapster-pods
  ports:
  - name: http
    port: 80
    targetPort: whatever-is-heapster-is-listening-on
SVC

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM