k8sのメトリクス収集方法として、kubectl get topコマンドを行う前に
以下の導入が必要となる。
1)以下のソースコードをダウンロードする
wget https://github.com/kubernetes-incubator/metrics-server/archive/v0.3.3.tar.gz
tar xzf v0.3.3.tar.gz
2)編集を行う
vi metrics-server-0.3.3/deploy/1.8+/metrics-server-deployment.yaml
3)デプロイを行う
kubectl apply -f metrics-server-0.3.3/deploy/1.8+/
wget https://github.com/kubernetes-incubator/metrics-server/archive/v0.3.3.tar.gz
tar xzf v0.3.3.tar.gz
2)編集を行う
vi metrics-server-0.3.3/deploy/1.8+/metrics-server-deployment.yaml
3)デプロイを行う
kubectl apply -f metrics-server-0.3.3/deploy/1.8+/
vi metrics-server-0.3.3/deploy/1.8+/metrics-server-deployment.yaml
①②以下のコマンドで、対応しているapiのバージョンを確認する
kubectl api-versions | grep apps
③以下の編集を行う。(赤文字変更箇所)
metrics-server-0.3.3/deploy/1.8+/metrics-server-deployment.yaml
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: metrics-server
namespace: kube-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: metrics-server
namespace: kube-system
labels:
k8s-app: metrics-server
spec:
selector:
matchLabels:
k8s-app: metrics-server
template:
metadata:
name: metrics-server
labels:
k8s-app: metrics-server
spec:
serviceAccountName: metrics-server
volumes:
# mount in tmp so we can safely use from-scratch images and/or read-only containers
- name: tmp-dir
emptyDir: {}
containers:
- name: metrics-server
image: k8s.gcr.io/metrics-server-amd64:v0.3.2
imagePullPolicy: Always
command:
- /metrics-server
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalDNS,InternalIP,ExternalDNS,ExternalIP,Hostname
volumeMounts:
- name: tmp-dir
mountPath: /tmp
apiVersion: v1
kind: ServiceAccount
metadata:
name: metrics-server
namespace: kube-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: metrics-server
namespace: kube-system
labels:
k8s-app: metrics-server
spec:
selector:
matchLabels:
k8s-app: metrics-server
template:
metadata:
name: metrics-server
labels:
k8s-app: metrics-server
spec:
serviceAccountName: metrics-server
volumes:
# mount in tmp so we can safely use from-scratch images and/or read-only containers
- name: tmp-dir
emptyDir: {}
containers:
- name: metrics-server
image: k8s.gcr.io/metrics-server-amd64:v0.3.2
imagePullPolicy: Always
command:
- /metrics-server
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalDNS,InternalIP,ExternalDNS,ExternalIP,Hostname
volumeMounts:
- name: tmp-dir
mountPath: /tmp
--------------------------------------------------------
3)デプロイを行う
kubectl apply -f metrics-server-0.3.3/deploy/1.8+/
kubectl apply -f metrics-server-0.3.3/deploy/1.8+/
5)podのメトリクスを確認してみる
0 件のコメント:
コメントを投稿