[root@master ~]# kubectl top node error:metricsnotavailableyet[root@master ~]# kubectl top podW041413:34:35.19368813720top_pod.go:266]Metricsnotavailableforpoddefault/centos-758b7556f5-542wl,age:299h19m20.193680607serror:Metricsnotavailableforpoddefault/centos-758b7556f5-542wl,age:299h19m20.193680607s
[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)