metrics-server

Posted zisefeizhu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了metrics-server相关的知识,希望对你有一定的参考价值。

[root@hs-k8s-master01 k8s]# pwd
/data/k8s
[root@hs-k8s-master01 k8s]# cd metrics/
[root@hs-k8s-master01 metrics]# ls
[root@hs-k8s-master01 metrics]# git clone https://github.com/kubernetes-incubator/metrics-server.git

[root@hs-k8s-master01 metrics]# ls
metrics-server
[root@hs-k8s-master01 metrics]# cd metrics-server/
cmd/    deploy/ .git/   hack/   pkg/    test/   
[root@hs-k8s-master01 metrics]# cd metrics-server/deploy/
1.7/      1.8+/     docker/   minikube/ 
[root@hs-k8s-master01 metrics]# cd metrics-server/deploy/1.8+/
[root@hs-k8s-master01 1.8+]# ls
aggregated-metrics-reader.yaml  auth-reader.yaml         metrics-server-deployment.yaml  resource-reader.yaml
auth-delegator.yaml             metrics-apiservice.yaml  metrics-server-service.yaml

[root@hs-k8s-master01 1.8+]# cp metrics-server-deployment.yaml{,.b
[root@hs-k8s-master01 1.8+]# vim metrics-server-deployment.yaml
[root@hs-k8s-master01 1.8+]# vim metrics-server-deployment.yaml
[root@hs-k8s-master01 1.8+]# cat metrics-server-deployment.yaml | 
      # mount in tmp so we can safely use from-scratch images and/
        image: k8s.gcr.io/metrics-server-amd64:v0.3.6
        imagePullPolicy: Always
[root@hs-k8s-master01 1.8+]# vim metrics-server-deployment.yaml
[root@hs-k8s-master01 1.8+]# vim metrics-server-deployment.yaml
[root@hs-k8s-master01 1.8+]# diff metrics-server-deployment.yaml{,.bak} 
32,37c32
<         image: registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.6
<         command:
<           - /metrics-server
<           - --metric-resolution=30s
<           - --kubelet-insecure-tls
<           - --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP
---
>         image: k8s.gcr.io/metrics-server-amd64:v0.3.6
47c42
<           runAsNonRoot: false
---
>           runAsNonRoot: true
49c44
<         imagePullPolicy: IfNotPresent
---
>         imagePullPolicy: Always

[root@hs-k8s-master01 1.8+]# kubectl create -f .
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
serviceaccount/metrics-server created
deployment.apps/metrics-server created
service/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created

[root@hs-k8s-master01 1.8+]# kubectl top nodes
NAME              CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
bs-k8s-master02   702m         17%    1151Mi          40%       
bs-k8s-master03   848m         21%    1183Mi          41%       
bs-k8s-node01     455m         11%    574Mi           20%       
bs-k8s-node02     480m         12%    641Mi           22%       
bs-k8s-node03     401m         10%    584Mi           20%       
hs-k8s-master01   606m         15%    1293Mi          45%       

[root@hs-k8s-master01 1.8+]# kubectl top pods -n kube-system
NAME                                      CPU(cores)   MEMORY(bytes)   
calico-node-bjtbm                         149m         79Mi            
calico-node-m5vz7                         142m         42Mi            
etcd-bs-k8s-master02                      264m         106Mi           
etcd-hs-k8s-master01                      115m         98Mi            
kube-apiserver-bs-k8s-master02            221m         292Mi           
kube-apiserver-hs-k8s-master01            183m         283Mi           
kube-controller-manager-bs-k8s-master02   98m          49Mi            
kube-controller-manager-hs-k8s-master01   28m          22Mi            
kube-proxy-78mmw                          1m           27Mi            
kube-proxy-qtbr6                          46m          26Mi            
kube-scheduler-bs-k8s-master02            25m          22Mi            
kube-scheduler-hs-k8s-master01            36m          23Mi  

 

以上是关于metrics-server的主要内容,如果未能解决你的问题,请参考以下文章

kubernetes部署metrics-server

09-4.部署 metrics-server 插件

metrics-server 使用ssl外部证书

metrics-server

metrics-server

metrics-server v0.3.7部署