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 插件的安装

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