3.2 安装 metrics-server

metrics-server 仓库地址

3.2.1 部署 metrics-server

下载 metrics-server 清单文件

wget -O metrics-server-v0.6.0.yaml \
  https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.6.0/components.yaml

修改清单文件

sed -i 's@k8s.gcr.io/metrics-server@k8simage@' metrics-server-v0.6.0.yaml
sed -i '/args:/a\        - --kubelet-insecure-tls' metrics-server-v0.6.0.yaml

部署清单文件

kubectl apply -f metrics-server-v0.6.0.yaml

输出如下

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

3.2.2 验证 metrics-server

检查 nodes 指标获取情况

需要等待 metrics-serverpod 就绪之后再等它收集一会再看。

kubectl top nodes

输出如下

NAME     CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
k8s-m1   575m         14%    2334Mi          29%
k8s-m2   492m         12%    2090Mi          26%
k8s-m3   516m         12%    1815Mi          23%

检查 pods 指标获取情况

kubectl top pods

输出如下

NAME                               CPU(cores)   MEMORY(bytes)
myapp-797b896b4b-6ghf7             0m           4Mi
nginx-779c9459b8-dp4tq             0m           4Mi
rbd-provisioner-795476997d-9vlm4   5m           9Mi
rbd-provisioner-795476997d-fv847   1m           6Mi

nodespodsCPU 和内存指标显示正常。

Copyright © huangzhongde.cn 2021 all right reserved,powered by Gitbook该文件修订时间: 2022-01-28 21:41:24

results matching ""

    No results matching ""