我们如何通过命令行获取 Kubernetes 上每个 Pod 的真实资源使用情况(而不是资源请求)?
Heapster 已被弃用。
同时,Metrics-server 仍然不支持 kubectl top pod
.
我使用以下命令部署了 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
当我使用
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:)
指标服务器不支持
kubectl top
Resource Metrics API 如果有人已经解决了同样的问题,请帮助我。
谢谢。
最佳答案
Error from server (ServiceUnavailable): the server is currently unable to handle the request (get services http:heapster:)
听起来好像 heapster 部署忘记安装
Service
为 heapster
;我希望这会让你克服那个错误,但不知道它是否真的会导致 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
关于kubernetes - 如何在Kubernetes中获取Pod的资源使用情况?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51641057/