CentOS 7
Sponsored Link

Kubernetes : Deploy Metrics Server2018/04/15

 
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.30              eth0|10.0.0.51             eth0|10.0.0.52
+----------+-----------+   +-----------+----------+   +-----------+----------+
|   [ dlp.srv.world ]  |   | [ node01.srv.world ] |   | [ node02.srv.world ] |
|      Master Node     |   |      Worker Node     |   |      Worker Node     |
+----------------------+   +----------------------+   +----------------------+

[1] Deploy Metrics Server on Master Node.
[root@dlp ~]#
git clone https://github.com/kubernetes-sigs/metrics-server

Cloning into 'metrics-server'...
remote: Enumerating objects: 13392, done.
remote: Counting objects: 100% (590/590), done.
remote: Compressing objects: 100% (289/289), done.
remote: Total 13392 (delta 334), reused 473 (delta 288), pack-reused 12802
Receiving objects: 100% (13392/13392), 12.87 MiB | 24.91 MiB/s, done.
Resolving deltas: 100% (7045/7045), done.

[root@dlp ~]#
vi ./metrics-server/manifests/base/deployment.yaml
.....
.....
 containers:
      - name: metrics-server
        image: gcr.io/k8s-staging-metrics-server/metrics-server:master
        imagePullPolicy: IfNotPresent
        # line 22 : add
        command:
        - /metrics-server
        - --kubelet-insecure-tls
        - --kubelet-preferred-address-types=InternalIP
        args:
          - --cert-dir=/tmp
          - --secure-port=4443
          - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
          - --kubelet-use-node-status-port
.....
.....

[root@dlp ~]#
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@dlp ~]#
kubectl get pods -n kube-system

NAME                                    READY   STATUS    RESTARTS   AGE
coredns-558bd4d5db-f8cvh                1/1     Running   4          16h
coredns-558bd4d5db-tg8v6                1/1     Running   3          16h
etcd-dlp.srv.world                      1/1     Running   3          16h
kube-apiserver-dlp.srv.world            1/1     Running   3          16h
kube-controller-manager-dlp.srv.world   1/1     Running   3          16h
kube-flannel-ds-5vnv2                   1/1     Running   3          16h
kube-flannel-ds-lf65f                   1/1     Running   3          16h
kube-flannel-ds-wdvpn                   1/1     Running   4          16h
kube-proxy-mqs8c                        1/1     Running   3          16h
kube-proxy-wzh69                        1/1     Running   3          16h
kube-proxy-zjzzf                        1/1     Running   3          16h
kube-scheduler-dlp.srv.world            1/1     Running   3          16h
metrics-server-6f87b5f98d-dr6g7         0/1     Running   0          14s
# [metrics-server] pod has been deployed
[2] To display CPU and Memory resources, run like follows.
[root@dlp ~]#
kubectl top node

NAME               CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
dlp.srv.world      187m         2%     1292Mi          8%
node01.srv.world   181m         9%     412Mi           11%
node02.srv.world   38m          1%     371Mi           10%

[root@dlp ~]#
kubectl top pod

NAME                         CPU(cores)   MEMORY(bytes)
private-nginx                0m           4Mi
test-nginx-59ffd87f5-7gxkd   0m           1Mi
test-nginx-59ffd87f5-9dkwg   0m           4Mi
test-nginx-59ffd87f5-svd6q   0m           1Mi
Matched Content