kubernetes部署metricsserver

编程

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信息

以上是 kubernetes部署metricsserver 的全部内容, 来源链接: utcz.com/z/514079.html

回到顶部