zoukankan      html  css  js  c++  java
  • Kubernetes中DaemonSet方式部署Node-Exporter以及Prometheus中抓取Node-Exporter

    K8S中DaemonSet方式部署Node-Exporer配置文件

    apiVersion: apps/v1
    kind: DaemonSet
    metadata:
      name: node-exporter
      namespace: monitoring
      labels:
        k8s-app: node-exporter
    spec:
      selector:
        matchLabels:
            k8s-app: node-exporter
      template:
        metadata:
          labels:
            k8s-app: node-exporter
        spec:
          tolerations:    #污点配置,不往master上调度这个
            - effect: NoSchedule
              key: node-role.kubernetes.io/master
          containers:
          - image: quay.io/prometheus/node-exporter:v1.0.0
            imagePullPolicy: IfNotPresent
            name: prometheus-node-exporter
            ports:
            - containerPort: 9100
              hostPort: 9100
              protocol: TCP
              name: metrics
            volumeMounts:
            - mountPath: /host/proc
              name: proc
            - mountPath: /host/sys
              name: sys
            - mountPath: /host
              name: rootfs
            args:
            - --path.procfs=/host/proc
            - --path.sysfs=/host/sys
            - --path.rootfs=/host
          volumes:
            - name: proc
              hostPath:
                path: /proc
            - name: sys
              hostPath:
                path: /sys
            - name: rootfs
              hostPath:
                path: /
          hostNetwork: true
          hostPID: true
    ---
    apiVersion: v1
    kind: Service
    metadata:
      annotations:
        prometheus.io/scrape: "true"
      labels:
        k8s-app: node-exporter
      name: node-exporter
      namespace: monitoring
    spec:
      ports:
      - name: http
        port: 9100
        protocol: TCP
      selector:
        k8s-app: node-exporter

    Prometheus抓取Node-Exporter

      - job_name: 'kubernetes-node-exporter'
        kubernetes_sd_configs:
        - role: node
        relabel_configs:
        - source_labels: [__address__]
          regex: '(.*):10250'
          replacement: '${1}:9100'
          target_label: __address__
          action: replace
        - source_labels: [__meta_kubernetes_node_name]
          action: replace
          target_label: node
        - action: labelmap
          regex: __meta_kubernetes_node_label_(.+)
        - source_labels: [__meta_kubernetes_node_address_InternalIP]
          action: replace
          target_label: ip

    注意:这样是抓取不到AWS EC2上打的Tag的,只能抓取到K8S集群对每个Node打的Labels 

  • 相关阅读:
    Sum Root to Leaf Numbers
    Sum Root to Leaf Numbers
    Sort Colors
    Partition List
    Binary Tree Inorder Traversal
    Binary Tree Postorder Traversal
    Remove Duplicates from Sorted List II
    Remove Duplicates from Sorted List
    Search a 2D Matrix
    leetcode221
  • 原文地址:https://www.cnblogs.com/chadiandianwenrou/p/14047143.html
Copyright © 2011-2022 走看看