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
 
相关推荐
IT WorryFree2 分钟前
GitHub Actions 流水线注入敏感配置完整方案(Antora + Docker Compose)
docker·容器·github
java_cj21 分钟前
从kubectl源码学Cobra:打造专业级Go命令行工具的完整实践
运维·开发语言·后端·云原生·golang·kubernetes·k8s
梦想的颜色38 分钟前
Dockerfile 深度实战:从指令底层原理到生产级镜像构建的艺术
docker·容器·镜像·dockerfile·dockerfile解析
heimeiyingwang1 小时前
【架构实战】Docker容器化:从镜像到部署的完整实践
docker·容器·架构
yuezhilangniao3 小时前
**国内阿里云环境**ubuntu22安装k8s1.32
阿里云·kubernetes·云计算
遇见火星10 小时前
Docker Compose 完全入门:一键启动所有容器
运维·docker·容器·docker compose
蘋天纬地16 小时前
k8s的控制平面是什么,有什么作用
容器·kubernetes
无级程序员17 小时前
clklog地域分析中的地名中英文对照问题解决
kubernetes
加加and减减20 小时前
Docker真实安装mysql8教程并优化配置
运维·mysql·docker·容器
qiuziqiqi1 天前
ocker-compose.yml 和Dockerfile 区别
运维·docker·容器