Ubuntu 24.04
Sponsored Link

Kubernetes : Deploy Metrics Server2024/06/07

 
Deploy Metrics Server to monitor CPU and Memory resources in Kubernetes Cluster.
This example is based on the environment like follows.
+----------------------+   +----------------------+
|  [ ctrl.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@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
        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@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 created

root@ctrl:~#
kubectl get pods -n kube-system

NAME                                     READY   STATUS    RESTARTS        AGE
calico-kube-controllers-57cf4498-7pjz8   1/1     Running   2 (5m45s ago)   4h39m
calico-node-29k45                        1/1     Running   2 (4m10s ago)   4h35m
calico-node-7gst9                        1/1     Running   2 (3m43s ago)   4h34m
calico-node-ndt9g                        1/1     Running   2 (5m45s ago)   4h39m
coredns-7db6d8ff4d-mxcrb                 1/1     Running   2 (5m45s ago)   4h40m
coredns-7db6d8ff4d-tvpmx                 1/1     Running   2 (5m45s ago)   4h40m
etcd-dlp.srv.world                       1/1     Running   3 (5m45s ago)   4h40m
kube-apiserver-dlp.srv.world             1/1     Running   3 (5m45s ago)   4h40m
kube-controller-manager-dlp.srv.world    1/1     Running   3 (5m45s ago)   4h40m
kube-proxy-bmz4b                         1/1     Running   2 (5m45s ago)   4h40m
kube-proxy-mxw6t                         1/1     Running   2 (3m43s ago)   4h34m
kube-proxy-tzjtn                         1/1     Running   2 (4m10s ago)   4h35m
kube-scheduler-dlp.srv.world             1/1     Running   3 (5m45s ago)   4h40m
metrics-server-69cdf995d7-sgpwn          1/1     Running   0               77s
# [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%
dlp.srv.world      121m         1%     1577Mi          9%
node01.srv.world   43m          0%     780Mi           4%
node02.srv.world   38m          0%     757Mi           4%

root@ctrl:~#
kubectl top pod

NAME                          CPU(cores)   MEMORY(bytes)
test-nginx-6cc69bb979-7zvzn   5m           7Mi
test-nginx-6cc69bb979-b6dxs   8m           17Mi
test-nginx-6cc69bb979-nfn8b   9m           17Mi
Matched Content