【K8S】K8s部署Metrics-Server服务
Metrics API 只可以查询当前的度量数据,并不保存历史数据Metrics API URI 为,在维护必须部署 metrics-server 才能使用该 API,metrics-server 通过调用 Kubelet Summary API 获取数据部署Metrics-Server服务。
-
Metrics API 只可以查询当前的度量数据,并不保存历史数据
-
Metrics API URI 为
/apis/metrics.k8s.io/
,在 k8s.io/metrics维护 -
必须部署 metrics-server 才能使用该 API,metrics-server 通过调用 Kubelet Summary API 获取数据
1.下载并解压Metrics-Server
https://github.com/kubernetes-sigs/metrics-server/archive/v0.3.6.tar.gz
tar -zxvf v0.3.6.tar.gz
2.修改Metrics-Server配置文件
cd metrics-server-0.3.6/deploy/1.8+/
vim metrics-server-deployment.yaml
vim metrics-server-deployment.yaml文件原有的内容如下所示。
apiVersion: v1
kind: ServiceAccount
metadata:
name: metrics-server
namespace: kube-system
apiVersion: apps/v1
kind: Deployment
metadata:
name: metrics-server
namespace: kube-system
labels:
k8s-app: metrics-server
spec:
selector:
matchLabels:
k8s-app: metrics-server
template:
metadata:
name: metrics-server
labels:
k8s-app: metrics-server
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: k8s.gcr.io/metrics-server-amd64:v0.3.6
imagePullPolicy: Always
volumeMounts:
- name: tmp-dir
mountPath: /tmp
修改后的文件内容如下所示。
apiVersion: v1
kind: ServiceAccount
metadata:
name: metrics-server
namespace: kube-system
apiVersion: apps/v1
kind: Deployment
metadata:
name: metrics-server
namespace: kube-system
labels:
k8s-app: metrics-server
spec:
selector:
matchLabels:
k8s-app: metrics-server
template:
metadata:
name: metrics-server
labels:
k8s-app: metrics-server
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 和 imagePullPolicy
image: mirrorgooglecontainers/metrics-server-amd64:v0.3.6
imagePullPolicy: IfNotPresent
新增command配置
command:
-
/metrics-server
-
–kubelet-insecure-tls
-
–kubelet-preferred-address-types=InternalDNS,InternalIP,ExternalDNS,ExternalIP,Hostname
volumeMounts:
- name: tmp-dir
mountPath: /tmp
新增resources配置
resources:
limits:
cpu: 300m
memory: 200Mi
requests:
cpu: 200m
memory: 100Mi
修改完metrics-server-deployment.yaml文件后保存退出。
3.安装Metrics-Server
执行如下命令安装Metrics-Server。
kubectl apply -f metrics-server-0.3.6/deploy/1.8+/
更多推荐
所有评论(0)