Skip to content

Commit

Permalink
Merge pull request #72 from nautible/feature/update-metrics-server
Browse files Browse the repository at this point in the history
Feature/update metrics server
  • Loading branch information
SaitoMunenori authored Feb 1, 2024
2 parents 7242cde + ae6a7be commit 80515d8
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 11 deletions.
54 changes: 49 additions & 5 deletions metrics-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,71 @@

## 1. 概要

クラスタ内のリソース使用状況を取得するメトリクスサーバー
クラスタ内のリソース使用状況を取得するメトリクスサーバー。ノード単位、Pod単位の基本的なメトリクス(CPU、メモリなど)を取得することができる。

AWS(EKS)にはデフォルトで導入されないため、メトリクスを取得する際は導入する必要がある。

## 2. 導入

```
$ kubectl apply -f metrics-server/application.yaml
```bash
kubectl apply -f metrics-server/application.yaml
```

## 3. 確認

### メトリクスサーバーの動作確認

```bash
kubectl get deployment metrics-server -n kube-system
```
$ kubectl get deployment metrics-server -n kube-system

<pre>
NAME READY UP-TO-DATE AVAILABLE AGE
metrics-server 1/1 1 1 6m
</pre>

### メトリクスの確認

```bash
kubectl top node
```

<pre>
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
ip-192-168-1-71.ap-northeast-1.compute.internal 26m 1% 626Mi 19%
ip-192-168-2-120.ap-northeast-1.compute.internal 25m 1% 576Mi 18%
ip-192-168-2-90.ap-northeast-1.compute.internal 25m 1% 701Mi 22%
</pre>

```bash
kubectl top pod -n kube-system
```

<pre>
NAME CPU(cores) MEMORY(bytes)
aws-node-dsnl5 3m 56Mi
aws-node-m82bm 2m 56Mi
aws-node-nppl7 2m 57Mi
coredns-6c4ffd9cc7-98wch 1m 12Mi
coredns-6c4ffd9cc7-xsj6t 1m 12Mi
ebs-csi-controller-5cd87b44cd-n5wwq 2m 52Mi
ebs-csi-controller-5cd87b44cd-scw8r 3m 51Mi
ebs-csi-node-hmm9h 1m 19Mi
ebs-csi-node-klpj5 1m 19Mi
ebs-csi-node-mf2js 1m 19Mi
kube-proxy-hpjnr 1m 11Mi
kube-proxy-l9stm 1m 11Mi
kube-proxy-xkp8j 1m 11Mi
metrics-server-967bc8b5c-h6pw7 2m 14Mi
</pre>

## 4. 削除

ArgoCDのコンソール画面よりmetrics-serverの削除を行う。

kubectlによる削除を行う場合は、Applicationリソースおよびmetrics-serverリソースの両方を削除する。

```
$ kubectl delete -f metrics-server/application.yaml
kubectl delete -f metrics-server/application.yaml
kubectl delete -f metrics-server/manifests/.
```
27 changes: 21 additions & 6 deletions metrics-server/manifests/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ metadata:
k8s-app: metrics-server
name: system:metrics-server
rules:
- apiGroups:
- ""
resources:
- nodes/metrics
verbs:
- get
- apiGroups:
- ""
resources:
- pods
- nodes
- nodes/stats
- namespaces
- configmaps
verbs:
- get
- list
Expand Down Expand Up @@ -130,10 +133,11 @@ spec:
containers:
- args:
- --cert-dir=/tmp
- --secure-port=4443
- --secure-port=10250
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-use-node-status-port
image: registry.k8s.io/metrics-server/metrics-server:v0.4.4
- --metric-resolution=15s
image: registry.k8s.io/metrics-server/metrics-server:v0.7.0
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
Expand All @@ -144,7 +148,7 @@ spec:
periodSeconds: 10
name: metrics-server
ports:
- containerPort: 4443
- containerPort: 10250
name: https
protocol: TCP
readinessProbe:
Expand All @@ -153,11 +157,22 @@ spec:
path: /readyz
port: https
scheme: HTTPS
initialDelaySeconds: 20
periodSeconds: 10
resources:
requests:
cpu: 100m
memory: 200Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
volumeMounts:
- mountPath: /tmp
name: tmp-dir
Expand Down

0 comments on commit 80515d8

Please sign in to comment.