Ubuntu 22.04
Sponsored Link

Kubernetes : Deploy Metrics Server2022/11/03

 
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 created

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

NAME                                       READY   STATUS    RESTARTS        AGE
calico-kube-controllers-59697b644f-fgfqp   1/1     Running   1 (6m30s ago)   23h
calico-node-8hjm5                          1/1     Running   1 (6m15s ago)   23h
calico-node-ck5zq                          1/1     Running   1 (6m11s ago)   23h
calico-node-z8vgs                          1/1     Running   1 (6m30s ago)   23h
coredns-565d847f94-v8v2x                   1/1     Running   1 (6m30s ago)   24h
coredns-565d847f94-zh4rd                   1/1     Running   1 (6m30s ago)   24h
etcd-ctrl.srv.world                        1/1     Running   1 (6m30s ago)   24h
kube-apiserver-ctrl.srv.world              1/1     Running   1 (6m30s ago)   24h
kube-controller-manager-ctrl.srv.world     1/1     Running   1 (6m30s ago)   24h
kube-proxy-9hmsh                           1/1     Running   1 (6m15s ago)   23h
kube-proxy-lnvhj                           1/1     Running   1 (6m30s ago)   24h
kube-proxy-zftff                           1/1     Running   1 (6m11s ago)   23h
kube-scheduler-ctrl.srv.world              1/1     Running   1 (6m30s ago)   24h
metrics-server-6776c5c959-5plm8            1/1     Running   0               88s
# [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      206m         2%     995Mi           6%
snode01.srv.world   68m          0%     450Mi           2%
snode02.srv.world   234m         2%     464Mi           2%

root@ctrl:~#
kubectl top pod

NAME                          CPU(cores)   MEMORY(bytes)
test-nginx-5d84c8d9d4-78287   0m           6Mi
test-nginx-5d84c8d9d4-cdsrt   0m           6Mi
test-nginx-5d84c8d9d4-npnd5   0m           6Mi
Matched Content