编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

容器监控cadvisor的介绍和使用(容器状态监控)

wxchong 2024-07-08 23:37:12 开源技术 14 ℃ 0 评论

容器监控cadvisor的介绍和使用

k8s 在 1.12 中将 cadvisor 从 kubelet 中移除了,若要使用 cadvisor,官方建议使用 DaemonSet 进行部署

一:cadvisor deamonset 配置

#cadvisor.yaml

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: cadvisor
  namespace: kube-system
  labels:
    app: cadvisor
spec:
  selector:
    matchLabels:
      name: cadvisor
  template:
    metadata:
      labels:
        name: cadvisor
    spec:
      hostNetwork: true
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
        key: enabledDiskSchedule
        value: "true"
        effect: NoSchedule
      containers:
      - name: cadvisor
        #image: k8s4:5000/cadvisor:latest  
        image: google/cadvisor:latest  
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: rootfs
          mountPath: /rootfs
          readOnly: true
        - name: var-run
          mountPath: /var/run
          readOnly: false
        - name: sys
          mountPath: /sys
          readOnly: true
        - name: docker
          mountPath: /var/lib/docker
          readOnly: true
        ports:
          - name: http
            containerPort: 4194
            protocol: TCP
        readinessProbe:
          tcpSocket:
            port: 4194
          initialDelaySeconds: 5
          periodSeconds: 10
        args:
          - --housekeeping_interval=10s
          - --port=4194
          - --storage_driver=influxdb
          - --storage_driver_db=cadvisor
          - --storage_driver_host=192.168.10.37:8086
      terminationGracePeriodSeconds: 30
      volumes:
      - name: rootfs
        hostPath:
          path: /
      - name: var-run
        hostPath:
          path: /var/run
      - name: sys
        hostPath:
          path: /sys
      - name: docker
        hostPath:
          path: /var/lib/docker


二:cadvisor单节点部署

一:单节点上部署

docker run \

--volume=/:/rootfs:ro \

--volume=/var/run:/var/run:rw \

--volume=/sys:/sys:ro \

--volume=/var/lib/docker/:/var/lib/docker:ro \

--publish=8090:8080 \

--detach=true \

--name=cadvisor \

k8s4:5000/cadvisor


三:通过节点端口访问

http://192.168.10.38:4194/containers

指标详细信息

http://192.168.10.38:4194/metrics



Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表