CONTRIBUTING.md Gopkg.toml Makefile pkg vendor
[root@master kubernetes-sigs-metrics-server-d1f4f6f]# cd deploy/
[root@master deploy]# ls
1.7 1.8+ docker minikube
[root@master deploy]# cd 1.8+/
[root@master 1.8+]# ls
aggregated-metrics-reader.yaml metrics-apiservice.yaml resource-reader.yaml
auth-delegator.yaml metrics-server-deployment.yaml
auth-reader.yaml metrics-server-service.yaml
[root@master 1.8+]#
#注意,当前在这个路径
[root@master 1.8+]# pwd
/k8s/kubernetes-sigs-metrics-server-d1f4f6f/deploy/1.8+
[root@master 1.8+]#
配置文件修改
[root@master 1.8+]# pwd
/k8s/kubernetes-sigs-metrics-server-d1f4f6f/deploy/1.8+
[root@master 1.8+]#
[root@master 1.8+]# vim metrics-server-deployment.yaml
下面行号中33行imagePullPolicy的值改为IfNotPresent
#并且34-38是新增内容,复制过去即可
…
33 imagePullPolicy: IfNotPresent
34 command:
35 - /metrics-server
36 - --metric-resolution=30s
37 - --kubelet-insecure-tls
38 - --kubelet-preferred-address-types=InternalIP
…
修改完成后是这样的
[root@master 1.8+]# cat metrics-server-deployment.yaml | grep -A 6 imagePullPolicy
imagePullPolicy: IfNotPresent
command:
-
/metrics-server
-
–metric-resolution=30s
-
–kubelet-insecure-tls
-
–kubelet-preferred-address-types=InternalIP
volumeMounts:
[root@master 1.8+]#
应用修改配置
复制下面的命令即可【.
是应用当前位置所有配置文件】
[root@master 1.8+]# pwd
/k8s/kubernetes-sigs-metrics-server-d1f4f6f/deploy/1.8+
[root@master 1.8+]#
[root@master 1.8+]# kubectl apply -f .
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
Warning: rbac.authorization.k8s.io/v1beta1 ClusterRoleBinding is deprecated in v1.17+, unavailable in v1.22+; use rbac.authorization.k8s.io/v1 ClusterRoleBinding
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
Warning: rbac.authorization.k8s.io/v1beta1 RoleBinding is deprecated in v1.17+, unavailable in v1.22+; use rbac.authorization.k8s.io/v1 RoleBinding
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
Warning: apiregistration.k8s.io/v1beta1 APIService is deprecated in v1.19+, unavailable in v1.22+; use apiregistration.k8s.io/v1 APIService
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
serviceaccount/metrics-server created
deployment.apps/metrics-server created
service/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
[root@master 1.8+]#
配置文件重命名
不做也可,做了更规范一点,没坏处。
[root@master 1.8+]# pwd
/k8s/kubernetes-sigs-metrics-server-d1f4f6f/deploy/1.8+
[root@master 1.8+]#
[root@master 1.8+]# cd /k8s
[root@master k8s]# ls | grep kubernetes-sigs-metrics-server-d1f4f6f/
[root@master k8s]# ls | grep kubernetes-sigs-metr
kubernetes-sigs-metrics-server-d1f4f6f
[root@master k8s]#
[root@master k8s]# mv kubernetes-sigs-metrics-server-d1f4f6f/ metric
[root@master k8s]#
至此,metrics就配置完成了。
metrics服务状态查看
现在也可以看到metrics的pod状态是running的
命令:kubectl get pods -n kube-system
[root@master k8s]# kubectl get ns
NAME STATUS AGE
default Active 4d3h
kube-node-lease Active 4d3h
kube-public Active 4d3h
kube-system Active 4d3h
[root@master k8s]# kubectl get pods -n kube-system | tail -n 2
kube-scheduler-master 1/1 Running 12 4d3h
metrics-server-644c7f4f6d-xb9bz 1/1 Running 0 6m39s
[root@master k8s]#
- api中也有这个服务
[root@master ~]# kubectl api-versions | gr