---
# System prepended metadata

title: Kubernetes Metrics Server 安裝

---

Kubernetes Metrics Server 安裝
===


## 目錄

[TOC]


下載Metrics Server
---
從官方github下載
https://github.com/kubernetes-incubator/metrics-server
```
wget https://github.com/kubernetes-incubator/metrics-server/archive/master.zip
```
解壓縮
```
unzip master.zip
```

修改檔案
---
解壓縮完會得到一個 metrics-server-master 資料夾，
進入metrics-server-master/deploy/1.8+資料夾

修改 metrics-server-deployment.yaml
(加入command的部分)
```
containers:
      - name: metrics-server
        image: k8s.gcr.io/metrics-server-amd64:v0.3.3
        imagePullPolicy: Always
        volumeMounts:
        - name: tmp-dir
          mountPath: /tmp
        command:
        - /metrics-server
        - --kubelet-insecure-tls
        - --kubelet-preferred-address-types=InternalIP
```


佈署
---
曾經遇到的失敗: 錯誤訊息:1 node(s) had taints that the pod didn't tolerate.
因為設定的關係無法在master節點上部屬，
如果一定要在master節點佈署，輸入以下指令修改設定
```
kubectl taint nodes --all node-role.kubernetes.io/master-
```
佈署所有yaml

![](https://i.imgur.com/bDHICKY.png)

檢查
```
kubectl get apiservice
```
![](https://i.imgur.com/YRLHrDK.png)

測試
---
```
kubectl top nodes
kubectl top pod --all-namespaces
```




