Kubernetes : Deploy Metrics Server2023/07/28 |
Deploy Metrics Server to monitor CPU and Memory resources in Kubernetes Cluster. This example is based on the environment like follows. -----------+---------------------------+--------------------------+------------ | | | eth0|10.0.0.25 eth0|10.0.0.71 eth0|10.0.0.72 +----------+-----------+ +-----------+-----------+ +-----------+-----------+ | [ ctrl.srv.world ] | | [snode01.srv.world] | | [snode02.srv.world] | | Control Plane | | Worker Node | | Worker Node | +----------------------+ +-----------------------+ +-----------------------+ |
[1] | Deploy Metrics Server on Control Plane Node. |
root@ctrl:~# git clone https://github.com/kubernetes-sigs/metrics-server
root@ctrl:~#
vi ./metrics-server/manifests/base/deployment.yaml ..... ..... containers: - name: metrics-server image: gcr.io/k8s-staging-metrics-server/metrics-server:master imagePullPolicy: IfNotPresent # line 23 : add command: - /metrics-server - --kubelet-insecure-tls - --kubelet-preferred-address-types=InternalIP args: - --cert-dir=/tmp - --secure-port=10250 - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname - --kubelet-use-node-status-port - --metric-resolution=15s ..... .....root@ctrl:~# 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 createdroot@ctrl:~# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-56dd5794f-r7fvl 1/1 Running 0 5h57m
calico-node-89s9h 1/1 Running 0 5h57m
calico-node-txrgc 1/1 Running 0 69m
calico-node-x8qvh 1/1 Running 0 70m
coredns-787d4945fb-6nn4p 1/1 Running 0 6h2m
coredns-787d4945fb-qwxb5 1/1 Running 0 6h2m
etcd-ctrl.srv.world 1/1 Running 0 6h3m
kube-apiserver-ctrl.srv.world 1/1 Running 0 6h3m
kube-controller-manager-ctrl.srv.world 1/1 Running 0 6h3m
kube-proxy-fbfgj 1/1 Running 0 6h2m
kube-proxy-gc6ff 1/1 Running 0 69m
kube-proxy-zc2fn 1/1 Running 0 70m
kube-scheduler-ctrl.srv.world 1/1 Running 0 6h3m
metrics-server-5698b55c7d-q48zb 1/1 Running 0 50s
# [metrics-server] pod has been deployed
|
[2] | To display CPU and Memory resources, run like follows. |
root@ctrl:~# kubectl top node NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% ctrl.srv.world 117m 1% 1731Mi 10% snode01.srv.world 27m 0% 907Mi 11% snode02.srv.world 37m 0% 1017Mi 6%root@ctrl:~# kubectl top pod NAME CPU(cores) MEMORY(bytes) test-nginx-6b4d69f6f8-2jcb2 0m 7Mi test-nginx-6b4d69f6f8-pwc5f 0m 7Mi test-nginx-6b4d69f6f8-xjmd8 0m 4Mi |
Sponsored Link |
|