kubectl top 插件的安裝

1.下載yaml 文件

wget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/auth-delegator.yaml
wget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/metrics-server-service.yaml
wget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/auth-reader.yaml
wget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/metrics-apiservice.yaml
wget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/metrics-server-deployment.yaml
wget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/aggregated-metrics-reader.yaml
wget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/resource-reader.yaml

2. 修改metrics-server-deployment.yaml文件

核心配置:

 containers:
      - name: metrics-server
        image: k8s.gcr.io/metrics-server-amd64:v0.3.2
        imagePullPolicy: IfNotPresent
        #修改爲本地有鏡像優先使用
        command:
        - /metrics-server
        - --metric-resolution=30s
        - --kubelet-insecure-tls
        - --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP
        #容器的預設值 腳本
        volumeMounts:
        - name: tmp-dir
          mountPath: /tmp

3.拉取鏡像

docker pull k8s.gcr.io/metrics-server-amd64
由於該鏡像在國外所以可能使用其他途徑 代理上網或者本地導入
代理上網法

mkdir -p /etc/systemd/system/docker.service.d
#創建放代理的文件夾,默認沒有
echo '[Service]
Environment="HTTP_PROXY=192.168.0.26:8118" "HTTPS_PROXY=192.168.0.26:8118"' >/etc/systemd/system/docker.service.d/http-proxy.conf
#創建代理的配置件,前提得有能訪問到國外鏡像服務器的代理服務器
systemctl daemon-reload
systemctl restart docker
#重啓docker

以上腳本運行一下 就能pull 到國外鏡像了

本地導出導入法
先到拉取完畢的主機上導出
docker save -o metrics-server-amd64:v0.3.2.tar k8s.gcr.io/metrics-server-amd64:v0.3.2
#.tar 爲完成的打包文件,後面的是需要導出的鏡像名需要帶版本名,鏡像名用docker images 查看
導入
docker load <metrics-server-amd64\:v0.3.2.tar

4.應用
kubectl apply -f ./
#應用下載的所有yaml文件
kubectl get pod -n kube-system
#查看一下pod 是否正常
kubectl top 插件的安裝

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章