[root@master ~]# kubectl top node error:metricsnotavailableyet[root@master ~]# kubectl top podW0414 13:34:35.193688 13720 top_pod.go:266] Metrics not available for pod default/centos-758b7556f5-542wl, age: 299h19m20.193680607s
error:Metricsnotavailableforpoddefault/centos-758b7556f5-542wl,age:299h19m20.193680607s
查看metrics-server pod 日志
[root@master ~]# kubectl -n kube-system logs metrics-server-58c885686f-nlp25 ...E0414 05:34:32.752194 1 reststorage.go:135] unable to fetch node metrics for node "node1": no metrics known for node
E0414 05:34:32.752208 1 reststorage.go:135] unable to fetch node metrics for node "master": no metrics known for node
E0414 05:34:35.186237 1 reststorage.go:160] unable to fetch pod metrics for pod default/tomtest-86f7667d85-hxnzl: no metrics known for pod
E0414 05:34:35.186247 1 reststorage.go:160] unable to fetch pod metrics for pod default/centos-758b7556f5-542wl: no metrics known for pod
[root@master ~]# kubectl apply -f components.yaml [root@master ~]# kubectl top node NAMECPU(cores) CPU%MEMORY(bytes) MEMORY%master101m5%971Mi17%node172m1%914Mi3%[root@master ~]# kubectl top pod --all-namespacesNAMESPACENAMECPU(cores) MEMORY(bytes) ingress-nginxnginx-ingress-controller-c8848f54b-z2fwd4m181Mikube-systemcalico-kube-controllers-77c4b7448-n92dt1m14Mikube-systemcalico-node-nqltv12m53Mikube-systemcalico-node-rf9gh10m49Mikube-systemcoredns-6955765f44-579bp2m13Mikube-systemcoredns-6955765f44-7h4vh1m13Mikube-systemetcd-master12m108Mikube-systemkube-apiserver-master19m336Mikube-systemkube-controller-manager-master5m42Mikube-systemkube-proxy-24k9w1m22Mikube-systemkube-proxy-w48qf1m17Mikube-systemkube-scheduler-master2m18Mikube-systemmetrics-server-6ffdb54684-lg77c1m14Mi
接口测试
metrics-server 将node 和pod 的监控数据通过k8s 标准api 暴露出来。
AllendpointsareGETendpoints,rootedat/apis/metrics/v1alpha1/.Therewon't be support for the other REST methods.The list of supported endpoints:/nodes - all node metrics; type []NodeMetrics/nodes/{node} - metrics for a specified node; type NodeMetrics/namespaces/{namespace}/pods - all pod metrics within namespace with support for all-namespaces; type []PodMetrics/namespaces/{namespace}/pods/{pod} - metrics for a specified pod; type PodMetricsThe following query parameters are supported:labelSelector - restrict the list of returned objects by labels (list endpoints only)