返回介绍

PART Ⅰ : 容器云OPENSHIFT

PART Ⅱ:容器云 KUBERNETES

PART Ⅲ:持续集成与持续部署

PART Ⅴ:日志/监控/告警

PART Ⅵ:基础

PART Ⅶ:数据存储、处理

PART VIII:CODE

PART X:HACKINTOSH

PART XI:安全

Ceph Exporter

发布于 2024-06-08 21:16:46 字数 6148 浏览 0 评论 0 收藏 0

由于在Openshift集群外使用了Ceph RBD和Ceph Filesystem作为PV的后端动态存储文件系统,所以ceph的集群监控也可使用Prometheus体系中的Ceph Exporter,接入到Openshift集群中的Prometheus。

  ---
  apiVersion: extensions/v1beta1
  kind: DaemonSet
  metadata:
    labels:
      app: ceph-exporter
    name: ceph-exporter
  spec:
    selector:
      matchLabels:
        app: ceph-exporter
    template:
      metadata:
        labels:
          app: ceph-exporter
      spec:
        containers:
        - image: digitalocean/ceph_exporter
          imagePullPolicy: IfNotPresent
          name: ceph-exporter
          ports:
            - containerPort: 9128
              hostPort: 9128
              name: http
              protocol: TCP
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
          - mountPath: /etc/ceph
            name: ceph-confdir
        resources:
          limits:
            cpu: 200m
            memory: 400Mi
          requests:
            cpu: 100m
            memory: 200Mi 
        dnsPolicy: ClusterFirst
        hostNetwork: true
        hostPID: true
        nodeSelector:
          beta.kubernetes.io/os: linux
        restartPolicy: Always
        schedulerName: default-scheduler
        securityContext: {}
        serviceAccount: node-exporter #使用Node-Exporter创建的ServiceAccount
        serviceAccountName: node-exporter
        terminationGracePeriodSeconds: 30
        tolerations:
        - effect: NoSchedule
          key: node-role.kubernetes.io/master
        volumes:
        - hostPath:
            path: /etc/ceph           #将ceph节点的配置文件路径暴露给exporter
            type: ""
          name: ceph-confdir
    templateGeneration: 1
    updateStrategy:
      rollingUpdate:
        maxUnavailable: 1
      type: RollingUpdate
  ---
  apiVersion: v1
  kind: Endpoints
  metadata:
    labels:
      k8s-app: ceph-exporter
    name: ceph-exporter
  subsets:
    - addresses:
        - ip: 192.168.1.96
          nodeName: allinone.okd311.curiouser.com
          targetRef:
            kind: Pod
      ports:
        - name: http
          port: 9128
          protocol: TCP
  ---
  apiVersion: v1
  kind: Service
  metadata:
    annotations:
      prometheus.io/port: '9128'
      prometheus.io/scrape: 'true'
    labels:
      k8s-app: ceph-exporter
    name: ceph-exporter
  spec:
    clusterIP: None
    ports:
      - name: http
        port: 9128
        protocol: TCP
        targetPort: http
    selector:
      app: ceph-exporter
    sessionAffinity: None
    type: ClusterIP
  ---
  apiVersion: route.openshift.io/v1
  kind: Route
  metadata:
    annotations:
      openshift.io/host.generated: 'true'
    labels:
      k8s-app: ceph-exporter
    name: ceph-exporter
  spec:
    port:
      targetPort: http
    to:
      kind: Service
      name: ceph-exporter
      weight: 100
    wildcardPolicy: None
  1. 备份Prometheus原配置文件secret Prometheus原始配置secret文件

  2. 创建新的Prometheus配置secret

    在原Prometheus配置文件中添加consul 服务发现和ceph-exporter相关的配置

    ...省略...
    - job_name: consul-prometheus
     metrics_path: /monitor/prometheus
     scrape_interval: 20s
     scheme: http
     scrape_timeout: 5s
     consul_sd_configs:
       - server: consul-server.consul.svc:8500
         services: []
         scheme: http
         allow_stale: true
         refresh_interval: 20s
    - job_name: openshift-monitoring/ceph-exporter/0
     honor_labels: false
     kubernetes_sd_configs:
     - role: endpoints
       namespaces:
         names:
         - openshift-monitoring
     scrape_interval: 30s
     scheme: http
     relabel_configs:
     - action: keep
       source_labels:
       - __meta_kubernetes_service_label_k8s_app
       regex: ceph-exporter
     - action: keep
       source_labels:
       - __meta_kubernetes_endpoint_port_name
       regex: http
     - source_labels:
       - __meta_kubernetes_namespace
       target_label: namespace
     - source_labels:
       - __meta_kubernetes_pod_name
       target_label: pod
     - source_labels:
       - __meta_kubernetes_service_name
       target_label: service
     - source_labels:
       - __meta_kubernetes_service_name
       target_label: job
       replacement: ${1}
     - source_labels:
       - __meta_kubernetes_service_label_k8s_app
       target_label: job
       regex: (.+)
       replacement: ${1}
     - target_label: endpoint
       replacement: http
    ...省略...
    
  3. 替换Prometheus的POD secret

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文