Kubernetes : Deploy Metrics Server2023/10/20 |
Deploy Metrics Server to monitor CPU and Memory resources in Kubernetes Cluster.
This example is based on the environment like follows.
+----------------------+ +----------------------+ | [ mgr.srv.world ] | | [ dlp.srv.world ] | | Manager Node | | Control Plane | +-----------+----------+ +-----------+----------+ eth0|10.0.0.25 eth0|10.0.0.30 | | ------------+--------------------------+----------- | | eth0|10.0.0.51 eth0|10.0.0.52 +-----------+----------+ +-----------+----------+ | [ node01.srv.world ] | | [ node02.srv.world ] | | Worker Node#1 | | Worker Node#2 | +----------------------+ +----------------------+ |
[1] | Deploy Metrics Server. |
[root@mgr ~]# git clone https://github.com/kubernetes-sigs/metrics-server
[root@mgr ~]#
vi ./metrics-server/manifests/base/deployment.yaml ..... ..... containers: - name: metrics-server image: gcr.io/k8s-staging-metrics-server/metrics-server:master imagePullPolicy: IfNotPresent args: - --cert-dir=/tmp - --secure-port=10250 - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname - --kubelet-use-node-status-port - --metric-resolution=15s # line 29 : add - --kubelet-insecure-tls[root@mgr ~]# kubectl apply -k ./metrics-server/manifests/base/ serviceaccount/metrics-server created clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created clusterrole.rbac.authorization.k8s.io/system:metrics-server created rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created service/metrics-server created deployment.apps/metrics-server created apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created[root@mgr ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-57758d645c-ws2gd 1/1 Running 4 26h
calico-node-6cxp9 0/1 Running 4 26h
calico-node-8cdds 1/1 Running 4 25h
calico-node-p7t9r 1/1 Running 4 25h
coredns-5dd5756b68-rn87g 1/1 Running 4 27h
coredns-5dd5756b68-zmsks 1/1 Running 4 27h
etcd-dlp.srv.world 1/1 Running 4 27h
kube-apiserver-dlp.srv.world 1/1 Running 4 27h
kube-controller-manager-dlp.srv.world 1/1 Running 6 27h
kube-proxy-486n6 1/1 Running 4 25h
kube-proxy-5w2fk 1/1 Running 4 25h
kube-proxy-ktlgl 1/1 Running 4 27h
kube-scheduler-dlp.srv.world 1/1 Running 4 27h
metrics-server-5b948694c5-ztl6d 1/1 Running 0 79s
# [metrics-server] pod has been deployed
|
[2] | If Firewalld is running on Control Plane Node, allow BGP (Border Gateway Protocol) port. |
[root@dlp ~]# firewall-cmd --add-port=179/tcp success [root@dlp ~]# firewall-cmd --runtime-to-permanent success |
[3] | To display CPU and Memory resources, run like follows. |
[root@mgr ~]# kubectl top node NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% dlp.srv.world 105m 1% 1383Mi 8% node01.srv.world 21m 0% 735Mi 9% node02.srv.world 27m 0% 868Mi 5%[root@mgr ~]# kubectl top pod NAME CPU(cores) MEMORY(bytes) test-nginx-f5c579c7d-kt5jv 0m 7Mi test-nginx-f5c579c7d-q5c6d 0m 7Mi test-nginx-f5c579c7d-w2hvb 0m 11Mi |
Sponsored Link |