prometheus operator 监控redis-exporter
创建 redis-exporter service
apiVersion: v1 kind: Service metadata: labels: app: redis-ec-exporter k8s.kuboard.cn/name: redis-ec-exporter name: redis-ec-exporter namespace: monitoring spec: externalTrafficPolicy: Cluster ports: - name: wzhxkx nodePort: 31107 port: 9121 protocol: TCP targetPort: 9121 selector: app: redis-ec-exporter sessionAffinity: None type: NodePort status: loadBalancer: {}
创建 redis-exporter deploy 应用
apiVersion: apps/v1 kind: Deployment metadata: labels: app: redis-ec-exporter k8s.kuboard.cn/name: redis-ec-exporter name: redis-ec-exporter namespace: monitoring spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: redis-ec-exporter strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: creationTimestamp: null labels: app: redis-ec-exporter spec: containers: - args: - -redis.addr - redis://redis-ec.test:6379 image: oliver006/redis_exporter:latest imagePullPolicy: Always name: redis-ec-exporter ports: - containerPort: 9121 name: http protocol: TCP resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30
创建 redis-exporter servicemonitor
apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: labels: app: redis-ec-exporter name: redis-ec-exporter namespace: monitoring spec: endpoints: - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token interval: 15s port: wzhxkx relabelings: - action: replace regex: (.*) replacement: $1 sourceLabels: - __meta_kubernetes_pod_node_name targetLabel: instance scheme: http tlsConfig: insecureSkipVerify: true jobLabel: app selector: matchLabels: app: redis-ec-exporter
查看 prometheus target 添加效果: