CentOS 7
Sponsored Link

Kubernetes : Metrics Server の設定2018/04/15

 
Metrics Server を設定して、Kubernetes クラスターの CPU/メモリー リソースのメトリクスを収集/監視します。
当例では以下のような Kubernetes クラスター環境で設定します。
-----------+---------------------------+--------------------------+------------
           |                           |                          |
       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] Master ノードで Metrics Server を設定します。
[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
        # 22行目 : 追記
        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 が新規にデプロイされる
[2] CPU や メモリー の使用状況は以下のように確認できます。
[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
関連コンテンツ