K8S部署Metrics-Server
1)下載manifest的YAML
wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/high-availability-1.21+.yaml
2) 編輯
需要在新增- –kubelet-insecure-tls
containers:
- args:
- --kubelet-insecure-tls #新新增
- --cert-dir=/tmp
- --secure-port=10250
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-use-node-status-port
- --metric-resolution=15s
3)建立
[root@master100 ~]# kubectl apply -f high-availability-1.21+.yaml
[root@master100 ~]# kubectl logs -n kube-system metrics-server-86cc658b69-kll57 -f
I0612 15:19:55.179672 1 serving.go:374] Generated self-signed cert (/tmp/apiserver.crt, /tmp/apiserver.key)
I0612 15:19:55.845820 1 handler.go:275] Adding GroupVersion metrics.k8s.io v1beta1 to ResourceManager
I0612 15:19:55.958224 1 secure_serving.go:213] Serving securely on [::]:10250
I0612 15:19:55.958452 1 requestheader_controller.go:169] Starting RequestHeaderAuthRequestController
I0612 15:19:55.958478 1 shared_informer.go:311] Waiting for caches to sync for RequestHeaderAuthRequestController
I0612 15:19:55.958669 1 dynamic_serving_content.go:132] "Starting controller" name="serving-cert::/tmp/apiserver.crt::/tmp/apiserver.key"
I0612 15:19:55.959138 1 tlsconfig.go:240] "Starting DynamicServingCertificateController"
I0612 15:19:55.959354 1 configmap_cafile_content.go:202] "Starting controller" name="client-ca::kube-system::extension-apiserver-authentication::client-ca-file"
I0612 15:19:55.959470 1 shared_informer.go:311] Waiting for caches to sync for client-ca::kube-system::extension-apiserver-authentication::client-ca-file
I0612 15:19:55.959503 1 configmap_cafile_content.go:202] "Starting controller" name="client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file"
I0612 15:19:55.959510 1 shared_informer.go:311] Waiting for caches to sync for client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file
I0612 15:19:56.059987 1 shared_informer.go:318] Caches are synced for client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file
I0612 15:19:56.060087 1 shared_informer.go:318] Caches are synced for client-ca::kube-system::extension-apiserver-authentication::client-ca-file
I0612 15:19:56.060241 1 shared_informer.go:318] Caches are synced for RequestHeaderAuthRequestController
4) 檢視
[root@master100 ~]# kubectl top nodes
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
master100 204m 10% 2242Mi 28%
worker102 76m 3% 1414Mi 18%
worker103 79m 3% 1052Mi 13%
[root@master100 ~]#