Kubernetes Metrics API(Metrics Server)

发布时间:2020-07-31 01:08:37 作者:51eA
来源:网络 阅读:444

监控资源指标管道 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

推荐阅读:
  1. Kubernetes安装和部署metrics-server
  2. Kubernetes高级进阶之pod的自动扩容/缩容

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

the latest kubernet metrics server metrics apis

上一篇:用MacBook对交换机进行初始化配置

下一篇:angular2.0最新版环境搭建与常见问题

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》