标签:命令 number auth 否则 节点 serve secure Kubernete 架构
监控资源指标管道 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 146m 7% 992Mi 65%
node2 20m 2% 333Mi 19%
node3 23m 2% 351Mi 28%
[root@node1 ~]#
查看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
Kubernetes 监控日志排错之 Metrics Server
标签:命令 number auth 否则 节点 serve secure Kubernete 架构
原文地址:https://blog.51cto.com/51eat/2474332