#設定
基本はgithubのページの通りに設定していく。
一部追記が必要なため、yamlをダウンロードする。
$ wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
components.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
k8s-app: metrics-server
name: metrics-server
namespace: kube-system
spec:
selector:
matchLabels:
k8s-app: metrics-server
strategy:
rollingUpdate:
maxUnavailable: 0
template:
metadata:
labels:
k8s-app: metrics-server
spec:
containers:
- args:
- --cert-dir=/tmp
- --secure-port=443
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-use-node-status-port
- --metric-resolution=15s
image: k8s.gcr.io/metrics-server/metrics-server:v0.5.0
imagePullPolicy: IfNotPresent
+ command:
+ - /metrics-server
+ - --kubelet-insecure-tls
+ - --kubelet-preferred-address-types=InternalIP
#適用
$ kubectl apply -f components.yaml
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
#メトリクス収集確認
$ kubectl -n kube-system top pods
W0815 23:53:59.483427 528625 top_pod.go:140] Using json format to get metrics. Next release will switch to protocol-buffers, switch early by passing --use-protocol-buffers flag
NAME CPU(cores) MEMORY(bytes)
calico-kube-controllers-58497c65d5-gjbqc 4m 24Mi
calico-node-pkpbv 65m 141Mi
coredns-558bd4d5db-8qbv7 6m 16Mi
coredns-558bd4d5db-qfr55 6m 15Mi
etcd-xxxxccc 38m 46Mi
kube-apiserver-caltagx 103m 479Mi
kube-controller-manager-caltagx 23m 63Mi
kube-proxy-d68mn 1m 31Mi
kube-scheduler-caltagx 5m 23Mi
metrics-server-6468fcbb58-kf7mc 5m 19Mi