当前位置:网站首页>Kubernetes监控组件metrics-server部署
Kubernetes监控组件metrics-server部署
2022-07-19 15:43:00 【星哥玩云】
从 v1.8 开始,资源使用情况的度量(如容器的 CPU 和内存使用)可以通过 Metrics API 获取。注意:
- Metrics API 只可以查询当前的度量数据,并不保存历史数据
- Metrics API URI 为 /apis/metrics.k8s.io/,在 k8s.io/metrics 维护
- 必须部署 metrics-server 才能使用该 API,metrics-server 通过调用 Kubelet Summary API 获取数据
开启聚合层(Aggregation Layer)
关于聚合层的一些知识 聚合层运行在apiserver进程内部,允许用户为集群安装额外的Kubernetes风格的API,扩展core API的功能。聚合层需要启动apiserver的时候开启方可使用。
在用户注册扩展资源之前,聚合层什么也不做。用户要注册API,必需向系统中添加一个APIService对象,用来声明API的URL路径以及处理请求的后端APIService。此后,聚合层会将发往那个路径的所有请求(e.g. /apis/myextension.mycompany.io/v1/…)都转发给注册的APIService。
一般情况下,APIService对象以extension-apiserver运行在集群中的一个pod中,如果需要主动管理添加的资源,extension-apiserver还需要与一个或多个controlller进行关联,apiserver-builder为双方提供了一个框架。
Service Catalog是Kubernetes的一种API扩展实现,方便Kubernetes集群内部应用访问集群外部、由第三方管理、提供的服务,如由云供应商提供的数据库服务。Service Catalog的安装会为它所提供的服务提供extension-apiserver和controller两个扩展组件。
开启聚合层 修改apiserver配置文件,加入如下启动参数来启用aggregation layer:
--requestheader-client-ca-file=/etc/kubernetes/ssl/ca.pem --requestheader-allowed-names=aggregator --requestheader-extra-headers-prefix=X-Remote-Extra- --requestheader-group-headers=X-Remote-Group --requestheader-username-headers=X-Remote-User
部署 metrics-server
git clone https://github.com/kubernetes-incubator/metrics-server cd metrics-server kubectl create -f deploy/1.8+/
稍后就可以看到 metrics-server 运行起来:
kubectl -n kube-system get pods -l k8s-app=metrics-server
备注: 假如gcr.io的镜像访问不到可以将metrics-server-deployment.yaml中的镜像替换为:daocloud.io/liukuan73/metrics-server-amd64:v0.2.1
Metrics API
可以通过 kubectl proxy 来访问 Metrics API:
- http://127.0.0.1:8001/apis/metrics.k8s.io/v1beta1/nodes
- http://127.0.0.1:8001/apis/metrics.k8s.io/v1beta1/nodes/
- http://127.0.0.1:8001/apis/metrics.k8s.io/v1beta1/pods
- http://127.0.0.1:8001/apis/metrics.k8s.io/v1beta1/namespace//pods/
也可以直接通过 kubectl 命令来访问这些 API,比如:
- kubectl get –raw apis/metrics.k8s.io/v1beta1/nodes
- kubectl get –raw apis/metrics.k8s.io/v1beta1/pods
- kubectl get –raw apis/metrics.k8s.io/v1beta1/nodes/
- kubectl get –raw apis/metrics.k8s.io/v1beta1/namespace//pods/
边栏推荐
猜你喜欢
随机推荐
SVG创意下划线样式js特效
2021-07-07 & 08 Li Kou daily question - use hash table to solve the problem
Yuntu says digital asset chain: your God of digital asset property protection
js弹出图片Lightbox灯箱插件spotlight.js
【推荐阅读】超有用的漏洞扫描工具合集!
请教下flink cdc在sql里面如果有复杂select嵌套,遇到DELETE的binlog时,会
Communication between processes in UNIX
基于Jsp+Servlet+MySQL+Bootstrap简单的学生信息管理系统
js打字机动画js特效插件autotyperjs
VisualStudio突然无法启动显示log文件Error解决方法
A Comparative Analysis of Deep Learning Approaches for Network Intrusion Detection Systems (N-IDSs)
玩转时习知No.6 | 文档库的神奇之处,就在......
基于JSP+Servlet+MySQL的图书商城系统
LoRa的技术特点有哪些?
Being a detective in GIS: find criminal accomplices through ArcGIS Pro
CM4开发之交叉编译工具链制作
基于JSP+Servlet+MySQL简单的酒店后台管理系统
Paper reading - using time series data enhancement to improve the accuracy of global prediction models
Visual query (sp_helptext) -- quick query of stored procedures containing specified strings (with source code)
flink目前的能力能支持source(mysql)一张表同步到sink(mysql)实现分库分表吗