Ubuntu 20.04
Sponsored Link

Kubernetes : Metrics Server の設定2020/08/19

 
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: 45, done.
remote: Counting objects: 100% (45/45), done.
remote: Compressing objects: 100% (39/39), done.
remote: Total 12244 (delta 12), reused 21 (delta 2), pack-reused 12199
Receiving objects: 100% (12244/12244), 12.47 MiB | 4.70 MiB/s, done.
Resolving deltas: 100% (6388/6388), 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
        # 32行目 : 追記
        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
poddisruptionbudget.policy/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-66bff467f8-jhjp9                1/1     Running   1          4h31m
coredns-66bff467f8-xz6g2                1/1     Running   1          4h31m
etcd-dlp.srv.world                      1/1     Running   1          4h31m
kube-apiserver-dlp.srv.world            1/1     Running   1          4h31m
kube-controller-manager-dlp.srv.world   1/1     Running   1          4h31m
kube-flannel-ds-amd64-gz6qm             1/1     Running   2          4h29m
kube-flannel-ds-amd64-hnb44             1/1     Running   2          4h27m
kube-flannel-ds-amd64-rnwcn             1/1     Running   1          4h28m
kube-proxy-l56tg                        1/1     Running   1          4h31m
kube-proxy-mlmm5                        1/1     Running   1          4h27m
kube-proxy-rdx99                        1/1     Running   1          4h28m
kube-scheduler-dlp.srv.world            1/1     Running   1          4h31m
metrics-server-df657db46-5cc9l          2/2     Running   0          55s
# [metrics-server] pod が新規にデプロイされる
[2] CPU や メモリー の使用状況は以下のように確認できます。
root@dlp:~#
kubectl top node

NAME               CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
dlp.srv.world      156m         1%     824Mi           6%
node01.srv.world   47m          0%     723Mi           6%
node02.srv.world   42m          1%     472Mi           6%

root@dlp:~#
kubectl top pod

NAME                          CPU(cores)   MEMORY(bytes)
test-nginx-7b7d9954bd-4wtsf   0m           3Mi
test-nginx-7b7d9954bd-62mxb   0m           4Mi
test-nginx-7b7d9954bd-mn8t8   0m           3Mi
test-nginx-7b7d9954bd-vgsxf   0m           3Mi
関連コンテンツ