k8s集群查看 pod 或者node 负载发现发现缺少metrics-server

在所有节点上安装

        docker pull mirrorgooglecontainers/metrics-server-amd64:v0.3.6

修改版本

        docker tag mirrorgooglecontainers/metrics-server-amd64:v0.3.6 k8s.gcr.io/metrics-server-amd64:v0.3.6

主节点设置

        curl -Ls https://api.github.com/repos/kubernetes-sigs/metrics-server/tarball/v0.3.6 -o metrics-server-amd64-v0.3.6.tar.gz

解压:tar -xvf metrics-server-amd64-v0.3.6.tar.gz

修改yaml文件

vim kubernetes-sigs-metrics-server-d1f4f6f/deploy/1.8+/metrics-server-deployment.yaml

spec:
      serviceAccountName: metrics-server
      volumes:
      # mount in tmp so we can safely use from-scratch images and/or read-only containers
      - name: tmp-dir
        emptyDir: {}
      containers:
      - name: metrics-server
        image: k8s.gcr.io/metrics-server-amd64:v0.3.6
        imagePullPolicy: IfNotPresent
        command:
        - /metrics-server
        - --metric-resolution=30s
        - --kubelet-insecure-tls
        - --kubelet-preferred-address-types=InternalIP
        volumeMounts:
        - name: tmp-dir
          mountPath: /tmp

创建pod

kubectl apply -f .

查看pod

kubectl get pod -n kube-system 
NAME                                       READY   STATUS    RESTARTS   AGE
...
kube-scheduler-vms55.rhce.cc               1/1     Running   0          9h
metrics-server-bcfb98c76-dnh82             1/1     Running   0          14m

查看

[root@vms55 1.8+]# kubectl top pod 
W0824 20:07:21.532993   26416 top_pod.go:140] Using json format to get metrics. Next release will switch to protocol-buffers, switch early by passing --use-protocol-buffers flag
NAME   CPU(cores)   MEMORY(bytes)   
pod1   0m           4Mi             
pod2   0m           5Mi             
[root@vms55 1.8+]# kubectl top nodes
W0824 20:07:30.062841   26544 top_node.go:119] Using json format to get metrics. Next release will switch to protocol-buffers, switch early by passing --use-protocol-buffers flag
NAME            CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
vms55.rhce.cc   271m         13%    1374Mi          47%       
vms56.rhce.cc   160m         8%     1032Mi          35%       
vms57.rhce.cc   124m         6%     974Mi           33%     

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐