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
 
相关推荐
ltl1 小时前
CoreDNS 深度拆解:ndots、search domain 与那些坑人的 DNS
kubernetes
摇滚侠2 小时前
《Docker技术入门与实战 第4版》阅读笔记 2 Docker 镜像
笔记·docker·容器
阿里云云原生4 小时前
还在给 AI “喂冷饭”?8.28 上海沙龙:带你跨越 AI 实时上下文鸿沟
云原生·kafka
ly76895 小时前
Docker 从入门到实践:镜像、容器、Dockerfile 与 Docker Compose 详解
运维·docker·容器
有脚就行9 小时前
第33篇-KServe推理平台-标准化的K8s推理服务管理
人工智能·云原生·容器·kubernetes
名字还没想好☜10 小时前
Kubernetes StatefulSet 实战:为什么数据库不能用 Deployment 部署
数据库·云原生·容器·kubernetes·statefulset
欧阳天羲10 小时前
全屋智能家居一体化方案‑配套资料文档合集
云原生·eureka·智能家居
陈聪.10 小时前
Docker 核心知识整理:从入门到企业级应用
运维·docker·容器
云原生指北11 小时前
Docker Sandboxes 的隔离例外:共享 Skills 与宿主机 MCP
运维·docker·ai·容器·agent
瞬间&永恒~11 小时前
【Kubernetes】(七)Kubernetes控制器
云原生·容器·kubernetes