k8s—Metrics-Server部署
k8s—Metrics-Server部署Metrics-Server是集群核心监控数据的聚合器,用来替换之前的heapster。容器相关的 Metrics 主要来自于 kubelet 内置的 cAdvisor 服务,有了Metrics-Server之后,用户就可以通过标准的 Kubernetes API 来访问到这些监控数据。Metrics API 只可以查询当前的度量数据,并不保存历史数据。Me
k8s—Metrics-Server部署
-
Metrics-Server是集群核心监控数据的聚合器,用来替换之前的heapster。
-
容器相关的 Metrics 主要来自于 kubelet 内置的 cAdvisor 服务,有了Metrics-Server之后,用户就可以通过标准的 Kubernetes API 来访问到这些监控数据。
-
Metrics API 只可以查询当前的度量数据,并不保存历史数据。
-
Metrics API URI 为 /apis/metrics.k8s.io/,在 k8s.io/metrics 维护。
-
必须部署 metrics-server 才能使用该 API,metrics-server 通过调用 Kubelet Summary API 获取数据。
-
Metrics Server 并不是 kube-apiserver 的一部分,而是通过 Aggregator 这种插件机制,在独立部署的情况下同 kube-apiserver 一起统一对外服务的。
-
kube-aggregator 其实就是一个根据 URL 选择具体的 API 后端的代理服务器。
上传镜像到仓库
部署后查看Metrics-server的Pod日志
kubectl
修改yaml文件 将443改为4443.镜像地址修改为自己的地址
- kubectl apply -f components.yaml
报错:x509: certificate signed by unknown authority
启用TLS Bootstrap 证书签发
解决:每个结点编辑文件,重启
vim /var/lib/kubelet/config.yaml
serverTLSBootstrap: true #在文件的最后一行加入
systemctl restart kubelet重启
下边是因为我在其它节点多次重启上述文件,所以出现不止三个认证的问题,解决该问题只需要把所有没有通过认证的节点,通过认证即可
- kubectl get csr
- kubectl certificate approve csr-5hcdz
[root@server1 mnt]# kubectl get csr
NAME AGE SIGNERNAME REQUESTOR CONDITION
csr-5hcdz 6m49s kubernetes.io/kubelet-serving system:node:server3 Pending
csr-74thb 8m54s kubernetes.io/kubelet-serving system:node:server2 Pending
csr-95vf8 11m kubernetes.io/kubelet-serving system:node:server1 Approved,Issued
csr-h9mm4 6m51s kubernetes.io/kubelet-serving system:node:server2 Pending
csr-jwsx5 23m kubernetes.io/kubelet-serving system:node:server2 Approved,Issued
csr-jzzrp 23m kubernetes.io/kubelet-serving system:node:server3 Approved,Issued
csr-wkjvw 8m50s kubernetes.io/kubelet-serving system:node:server3 Pending
csr-wpfw7 26m kubernetes.io/kubelet-serving system:node:server1 Approved,Issued
[root@server1 mnt]# kubectl certificate approve csr-5hcdz
certificatesigningrequest.certificates.k8s.io/csr-5hcdz approved
[root@server1 mnt]# kubectl certificate approve csr-74thb
certificatesigningrequest.certificates.k8s.io/csr-74thb approved
[root@server1 mnt]# kubectl certificate approve csr-h9mm4
certificatesigningrequest.certificates.k8s.io/csr-h9mm4 approved
[root@server1 mnt]# kubectl certificate approve csr-wkjvw
certificatesigningrequest.certificates.k8s.io/csr-wkjvw approved
[root@server1 mnt]# kubectl get csr
NAME AGE SIGNERNAME REQUESTOR CONDITION
csr-5hcdz 7m17s kubernetes.io/kubelet-serving system:node:server3 Approved,Issued
csr-74thb 9m22s kubernetes.io/kubelet-serving system:node:server2 Approved,Issued
csr-95vf8 11m kubernetes.io/kubelet-serving system:node:server1 Approved,Issued
csr-h9mm4 7m19s kubernetes.io/kubelet-serving system:node:server2 Approved,Issued
csr-jwsx5 24m kubernetes.io/kubelet-serving system:node:server2 Approved,Issued
csr-jzzrp 24m kubernetes.io/kubelet-serving system:node:server3 Approved,Issued
csr-wkjvw 9m18s kubernetes.io/kubelet-serving system:node:server3 Approved,Issued
csr-wpfw7 26m kubernetes.io/kubelet-serving system:node:server1 Approved,Issued
-
kubectl -n kube-system get pod 查看是否ready
-
kubectl top node
[root@server1 mnt]# kubectl top node
W0803 18:29:27.334697 15783 top_node.go:119] Using json format to get metrics. Next release will switch to protocol-buffers, switch early by passing --use-protocol-buffers flag
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
server1 419m 20% 1233Mi 74%
server2 329m 32% 661Mi 74%
server3 116m 11% 606Mi 68%
部署成功!
更多推荐
所有评论(0)