CC00062.CloudKubernetes——|KuberNetes&二进制部署.V15|3台Server|——|kubernetes组件|metrics-server|

  • Post author:
  • Post category:其他


一、部署Metrics Server

### --- metrics server概述

~~~     在新版的Kubernetes中系统资源的采集均使用Metrics-server,
~~~     可以通过Metrics采集节点和Pod的内存、磁盘、CPU和网络的使用率。

### --- 部署metrics server
~~~     切换到metrics-server安装目录下

[root@k8s-master01 ~]# cd /root/k8s-ha-install/metrics-server-0.4.x/

### --- 部署metrics-server

[root@k8s-master01 metrics-server-0.4.x]# kubectl  create -f .
~~~     注:输出结果
serviceaccount/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
service/metrics-server created
deployment.apps/metrics-server created
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created

二、查看服务状态

### --- 等待metrics server启动然后查看状态
~~~     查看metrics-server.pod状态

[root@k8s-master01 metrics-server-0.4.x]# kubectl get po -n kube-system
NAME                                       READY   STATUS    RESTARTS   AGE
metrics-server-595f65d8d5-l6f7k            1/1     Running   0          69s

### --- 查看metrics-server监控到pod资源的状态
~~~     查看metrics监控状态

[root@k8s-master01 metrics-server-0.4.x]# kubectl top node
NAME           CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
k8s-master01   246m         12%    1622Mi          42%       
k8s-node01     171m         8%     712Mi           18%       
k8s-node02     277m         13%    657Mi           22%