kubernetes部署metrics-server

蓝咒 提交于 2020-03-04 00:06:27

下载yaml文件到目录中 https://github.com/kubernetes-sigs/metrics-server/tree/master/deploy/kubernetes

cd ~
mkdir metrics-server
cd metrics-server
wget https://raw.githubusercontent.com/kubernetes-sigs/metrics-server/master/deploy/kubernetes/aggregated-metrics-reader.yaml
wget https://raw.githubusercontent.com/kubernetes-sigs/metrics-server/master/deploy/kubernetes/auth-delegator.yaml
wget https://raw.githubusercontent.com/kubernetes-sigs/metrics-server/master/deploy/kubernetes/auth-reader.yaml
wget https://raw.githubusercontent.com/kubernetes-sigs/metrics-server/master/deploy/kubernetes/metrics-apiservice.yaml
wget https://raw.githubusercontent.com/kubernetes-sigs/metrics-server/master/deploy/kubernetes/metrics-server-deployment.yaml
wget https://raw.githubusercontent.com/kubernetes-sigs/metrics-server/master/deploy/kubernetes/metrics-server-service.yaml
wget https://raw.githubusercontent.com/kubernetes-sigs/metrics-server/master/deploy/kubernetes/resource-reader.yaml

修改metrics-server-deployment.yaml,( 由于主机名没有作DNS解析,所以croedns无法找到主机。 各种云上不会有这个问题,因为一般云上主机在云端内部DNS服务器上都是自动添加了DNS记录的,使用云端自有DNS就能解释了主机的IP,这个问题一般出现在本地部署。 ) 修改一行镜像,增加4行command,如下。

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: registry.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.6 # 改阿里云镜像
        args:
          - --cert-dir=/tmp
          - --secure-port=4443
        ports:
        - name: main-port
          containerPort: 4443
          protocol: TCP
        securityContext:
          readOnlyRootFilesystem: true
          runAsNonRoot: false
          runAsUser: 1000
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: tmp-dir
          mountPath: /tmp
        command: #增加
        - /metrics-server #增加
        - --kubelet-preferred-address-types=InternalIP #增加
        - --kubelet-insecure-tls #增加

编辑api-server,本例使用的kubeadm安装的

vi /etc/kubernetes/manifests/kube-apiserver.yaml

修改内容如下 

 - --requestheader-allowed-names=aggregator #修改为aggregator 
 - --enable-aggregator-routing=true # 增加一行

部署

kubectl apply -f .

dashboard自动就加载了cpu mem信息

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!