redis-exporter监控部署(k8s内)tensuns专用

发布时间:2024年01月19日

reidis-exporter服务需要用到configmap、service、deployment服务

创建存放yaml目录

mkdir?/opt/redis-exporter && cd?/opt/redis-exporter

编辑yaml配置文件

vi configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: redis-conf
  namespace: monitor
  labels:
    app: redis-exporter
data:
  redis_passwd.json: |-                  #填写各redis节点地址端口和密码
    {
      "redis://10.1.60.17:6379":"12345678",
      "redis://10.1.60.18:6379":"12345678",
      "redis://10.1.60.19:6379":"12345678"
    }

vi deployment.yaml

kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    app: redis-exporter
  name: redis-exporter
  namespace: monitor
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: redis-exporter
  template:
    metadata:
      labels:
        app: redis-exporter
    spec:
      containers:
        - name: redis-exporter
          image: oliver006/redis_exporter
          imagePullPolicy: IfNotPresent
          args:
            - --redis.password-file=/redis_passwd.json
          volumeMounts:
            - mountPath: /etc/localtime
              name: tz-config
            - mountPath: /redis_passwd.json
              name: redis-conf-volume
              subPath: redis_passwd.json   #使用subPath方式挂载配置文件
          ports:
            - containerPort: 9121
              protocol: TCP
      volumes:
        - name: tz-config   #挂载时间配置,与宿主机配置时间同步
          hostPath:
            path: /usr/share/zoneinfo/PRC
        - name: redis-conf-volume     #通过configmap挂载prometheus配置
          configMap:
            name: redis-conf

vi service.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    app: redis-exporter
  name: redis-exporter
  namespace: monitor
spec:
  type: NodePort
  ports:
  - name: http
    port: 9121
    targetPort: 9121
    nodePort: 30012
  selector:
    app: redis-exporter

创建各yaml服务

kubectl apply -f?configmap.yaml

kubectl apply -f deployment.yaml

kubectl apply -f service.yaml

查看redis-exporter pod是否正常运行

kubectl get pod -n monitor

文章来源:https://blog.csdn.net/ApexPredator/article/details/135701298
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。