n9e categraf k8s监控配置 -cadvisor

1、创建用户角色权限

bash 复制代码
vi  z-categraf-monitor-rbac.yaml
bash 复制代码
apiVersion: v1
kind: ServiceAccount
metadata:
  name: z-categraf-monitor
  namespace: z-monitor
  labels:
    app: categraf
    purpose: cadvisor-monitor
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: z-categraf-monitor-clusterrole
  labels:
    app: categraf
    purpose: cadvisor-monitor
rules:
  - nonResourceURLs:
      - "/metrics/cadvisor"
      - "/stats/summary"
      - "/pods"
      - "/nodes/proxy/metrics/cadvisor"
    verbs: ["get"]
  - apiGroups: [""]
    resources:
      - "nodes"
      - "nodes/metrics"
      - "nodes/stats"
      - "nodes/proxy"
    verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: z-categraf-monitor-clusterrolebinding
  labels:
    app: categraf
    purpose: cadvisor-monitor
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: z-categraf-monitor-clusterrole
subjects:
  - kind: ServiceAccount
    name: z-categraf-monitor
    namespace: z-monitor
bash 复制代码
kubectl apply -f z-categraf-monitor-rbac.yaml

2、获取token

bash 复制代码
# 提取Token
SECRET_NAME=$(kubectl get sa z-categraf-monitor -n z-monitor -o jsonpath='{.secrets[0].name}')
VALID_TOKEN=$(kubectl get secret $SECRET_NAME -n z-monitor -o jsonpath='{.data.token}' | base64 -d)

#  将Token写入文件
echo "$VALID_TOKEN" > /data/zz/z-categraf-monitor.token

3、每个节点配置 categraf/conf/input.cadvisor/cim-pord-cadvisor.toml

bash 复制代码
vi  cim-pord-cadvisor.toml
bash 复制代码
# # collect interval
interval = 15

[[instances]]
url = "https://127.0.0.1:10250"
type = "kubelet"

bearer_token_string = "eyxxxxx"
ignore_label_keys = ["id","name", "container_label*"]
insecure_skip_verify = true
use_tls = true
container_exclude = ["^POD$"]
# ignore_label_keys = ["id","name", "container_label*"]
## choose_label_keys = ["id"]

timeout = "15s"# # collect interval
 
相关推荐
分布式存储与RustFS15 小时前
浏览器调 RustFS 的 S3 接口被拦下来?两个 CORS 变量分开管 9000 和 9001
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
جيون داد ناالام ميづ15 小时前
五、Nacos 项目实战:企业级微服务落地方案
微服务·云原生·架构
AR-26710-16 小时前
docker Day6——容器数据卷
运维·docker·容器
AR-26710-18 小时前
docker Day5——改动+systemf复习
运维·docker·容器
always20221 天前
AI运行时 · 06 - Kata 与 K8s 集成:RuntimeClass / CSI kata-directvolume / 性能开销与调优
人工智能·容器·kubernetes
赤生云电竞1 天前
GPU算力共享平台架构实践:任务分发与资源隔离——基于NVIDIA MIG与Kubernetes调度器的工程化拆解
架构·kubernetes·gpu算力
Maiko Star2 天前
Docker保姆级部署AI应用程序(FastAPI)
docker·容器·fastapi
A-刘晨阳2 天前
Kubernetes 查询证书有效期及续签证书(适用于二进制部署)
云原生·容器·kubernetes·证书·cfssl
`Levie3 天前
Docker-安装部署、容器管理(一)
docker·容器·eureka
东风微鸣3 天前
QuePaxa VS Raft:广域网共识,为什么「慢但不停」胜过「快但一抖就死」
分布式·云原生·raft