root@hello:~/cby# kubectl apply -f metrics-rbac.yaml -n kube-system clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created clusterrole.rbac.authorization.k8s.io/system:metrics-server created clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created serviceaccount/metrics-server created
root@hello:~/cby# kubectl apply -f metrics-api-service.yaml -n kube-system apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
root@hello:~/cby# kubectl apply -f metrics-server-deploy.yaml -n kube-system Warning: spec.template.spec.nodeSelector[beta.kubernetes.io/os]: deprecated since v1.14; use "kubernetes.io/os" instead deployment.apps/metrics-server created service/metrics-server created root@hello:~/cby#
验证
root@hello:~/cby# kubectl get pod -A | grep metrics-server kube-system metrics-server-5c69d5d5b7-b6246 1/1 Running 0 2m25s root@hello:~/cby#
查看日志
root@hello:~/cby# kubectl logs -n kube-system metrics-server-5c69d5d5b7-b6246 I0328 07:11:37.676490 1 serving.go:341] Generated self-signed cert (/tmp/apiserver.crt, /tmp/apiserver.key) I0328 07:11:38.148457 1 requestheader_controller.go:169] Starting RequestHeaderAuthRequestController I0328 07:11:38.148472 1 configmap_cafile_content.go:202] Starting client-ca::kube-system::extension-apiserver-authentication::client-ca-file I0328 07:11:38.148507 1 shared_informer.go:240] Waiting for caches to sync for client-ca::kube-system::extension-apiserver-authentication::client-ca-file I0328 07:11:38.148475 1 configmap_cafile_content.go:202] Starting client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file I0328 07:11:38.148550 1 shared_informer.go:240] Waiting for caches to sync for client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file I0328 07:11:38.148490 1 shared_informer.go:240] Waiting for caches to sync for RequestHeaderAuthRequestController I0328 07:11:38.149073 1 dynamic_serving_content.go:130] Starting serving-cert::/tmp/apiserver.crt::/tmp/apiserver.key I0328 07:11:38.149428 1 secure_serving.go:202] Serving securely on [::]:4443 I0328 07:11:38.149535 1 tlsconfig.go:240] Starting DynamicServingCertificateController I0328 07:11:38.248713 1 shared_informer.go:247] Caches are synced for RequestHeaderAuthRequestController I0328 07:11:38.248732 1 shared_informer.go:247] Caches are synced for client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file I0328 07:11:38.248754 1 shared_informer.go:247] Caches are synced for client-ca::kube-system::extension-apiserver-authentication::client-ca-file root@hello:~/cby#
root@hello:~/cby# kubectl top pod -n kube-system metrics-server-5c69d5d5b7-b6246 NAME CPU(cores) MEMORY(bytes) metrics-server-5c69d5d5b7-b6246 4m 13Mi root@hello:~/cby#