十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
监控资源指标管道 Metrics API(Metrics Server)
专业领域包括成都做网站、成都网站建设、成都外贸网站建设、商城网站定制开发、微信营销、系统平台开发, 与其他网站设计及系统开发公司不同,创新互联建站的整合解决方案结合了帮做网络品牌建设经验和互联网整合营销的理念,并将策略和执行紧密结合,为客户提供全网互联网整合方案。
在Kubernetes集群中部署 Metrics API(Metrics Server)
[root@node1 metrics]# ll
total 24
-rw-r--r-- 1 root root 398 Feb 28 03:30 auth-delegator.yaml
-rw-r--r-- 1 root root 419 Feb 28 03:30 auth-reader.yaml
-rw-r--r-- 1 root root 388 Feb 28 03:30 metrics-apiservice.yaml
-rw-r--r-- 1 root root 3252 Feb 28 03:30 metrics-server-deployment.yaml
-rw-r--r-- 1 root root 336 Feb 28 03:30 metrics-server-service.yaml
-rw-r--r-- 1 root root 795 Feb 28 03:30 resource-reader.yaml
[root@node1 metrics]#
command: //此处修改
- /metrics-server
- --metric-resolution=30s
# These are needed for GKE, which doesn't support secure communication yet.
# Remove these lines for non-GKE clusters, and when GKE supports token-based auth.
- --kubelet-port=10250
#- --deprecated-kubelet-completely-insecure=true
- --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP
command: //此处修改
- /pod_nanny
- --config-dir=/etc/config
- --cpu=5m
- --extra-cpu=0.5m
- --memory=80Mi
- --extra-memory=8Mi
- --threshold=5
- --deployment=metrics-server-v0.3.6
- --container=metrics-server
- --poll-period=300000
- --estimator=exponential
# Specifies the smallest cluster (defined in number of nodes)
# resources will be scaled to.
#- --minClusterSize={{ metrics_server_min_cluster_size }}
rules:
- apiGroups:
- ""
resources:
- pods
- nodes
- namespaces
- nodes/stats
[root@node2 ~]# cat pull-metrics.sh
#!/bin/bash
#
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.6
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/addon-resizer:1.8.7
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.6 k8s.gcr.io/metrics-server-amd64:v0.3.6
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/addon-resizer:1.8.7 k8s.gcr.io/addon-resizer:1.8.7
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.6
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/addon-resizer:1.8.7
[root@node2 ~]#
[root@node1 metrics]# kubectl apply -f ./
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
configmap/metrics-server-config created
deployment.apps/metrics-server-v0.3.6 created
service/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
[root@node1 metrics]#
[root@node1 ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
metrics-server-v0.3.6-cf56dfd4-mj7p2 2/2 Running 0 22s
[root@node1 ~]# kubectl top nodes
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
node1 137m 6% 1043Mi 69%
node2 21m 2% 333Mi 20%
node3 23m 2% 343Mi 28%
查看node资源指标
[root@node1 metrics]# kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes" | jq | less
查看pods资源指标
[root@node1 metrics]# kubectl get --raw "/apis/metrics.k8s.io/v1beta1/pods" | jq | less
其它方式在Kubernetes 上部署Metrics Server的方法
此方法要比以上部署要容易许多,可参考之
github kubernetes-sigs