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
 
相关推荐
wxjlkh10 小时前
5分钟部署Docker!Rocky Linux极速安装+一键加速配置脚本
云原生·eureka
丈剑走天涯10 小时前
kubernetes java app 部署使用harbor私服 问题集合
java·容器·kubernetes
Jinkxs12 小时前
Java 部署:滚动更新(K8s RollingUpdate 策略)
java·开发语言·kubernetes
lpfasd12313 小时前
Kubernetes (K8s) 底层早已不再直接使用 Docker 引擎了
java·docker·kubernetes
不吃香菜kkk、14 小时前
通过夜莺n9e监控Kubernetes集群
安全·云原生·容器·kubernetes
淡泊if14 小时前
K8s 网络排障:从抓包开始,一步步定位诡异“502”
网络·kubernetes·k8s
小李的便利店15 小时前
k8s集群部署Prometheus和Grafana
kubernetes·grafana·prometheus·监控
margu_16815 小时前
【Docker】nscenter命令详解
运维·docker·容器
阿里云云原生15 小时前
Higress 加入 CNCF:保障 Nginx Ingress 迁移,提供企业级 AI 网关
云原生
道清茗16 小时前
【Kubernetes知识点问答题】Pod 调度
云原生·容器·kubernetes