thanos部署(四) -- store和compactor

本篇thanos部署是基于prometheus-operator,prometheus-operator为thanos提供了在CRD和controller上的支持。

store组件

  1. 部署store statefulset
    store提供了StoreAPI,以便querier查询object storage中的历史数据;
# cat thanos-store-sts.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: thanos-store
  namespace: monitoring
  labels:
    app: thanos-store
spec:
  serviceName: "thanos-store"
  replicas: 1
  selector:
    matchLabels:
      app: thanos-store
  template:
    metadata:
      labels:
        app: thanos-store
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "10902"
    spec:
      containers:
      - name: thanos-store
        image: thanosio/thanos:v0.18.0
        args:
        - "store"
        - "--log.level=debug"
        - "--data-dir=/var/thanos/store"
        - "--objstore.config-file=/config/thanos.yaml"
        ports:
        - name: http
          containerPort: 10902
        - name: grpc
          containerPort: 10901
        - name: cluster
          containerPort: 10900
        volumeMounts:
        - name: config
          mountPath: /config/
          readOnly: true
        - name: data
          mountPath: /var/thanos/store
      volumes:
      - name: data
        emptyDir: {}
      - name: config
        secret:
          secretName: thanos-objstore-config

volumes增加了之前创建的secret: thanos-objstore-conf,其配置了访问minio的方法;

  1. 部署store service
    部署svc主要是为querier组件使用,端口类型为clusterIP:
# cat thanos-store-svc.yaml
apiVersion: v1
kind: Service
metadata:
  name: thanos-store
  namespace: monitoring
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: grpc
      port: 10901
      targetPort: grpc
  selector:
    app: thanos-store
  1. 将store service的地址告诉querier组件
    修改thanos-querier-deploy.yaml,在querier启动参数,增加store的配置
containers:
      - name: thanos
        image: thanosio/thanos:v0.18.0
        args:
        - "query"
        - "--log.level=debug"
        - "--query.replica-label=prometheus_replica"
        - "--store=dnssrv+prometheus-operated:10901"
        - "--store=dnssrv+thanos-store:10901"

这里增加了store的svc: --store=dnssrv+thanos-store:10901

  1. 查看querier UI确认store添加OK
    thanos部署(四) -- store和compactor_第1张图片

compactor组件

  1. 部署compactor statefulset
# cat thanos-compactor-sts.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: thanos-compactor
  namespace: monitoring
  labels:
    app: thanos-compactor
spec:
  serviceName: "thanos-compactor"
  replicas: 1
  selector:
    matchLabels:
      app: thanos-compactor
  template:
    metadata:
      labels:
        app: thanos-compactor
    spec:
      containers:
      - name: thanos-compactor
        image: thanosio/thanos:v0.18.0
        args:
        - "compact"
        - "--log.level=debug"
        - "--data-dir=/var/thanos/store"
        - "--objstore.config-file=/config/thanos.yaml"
        - "--wait"
        ports:
        - name: http
          containerPort: 10902
        volumeMounts:
        - name: config
          mountPath: /config/
          readOnly: true
        - name: data
          mountPath: /var/thanos/store
      volumes:
      - name: data
        emptyDir: {}
      - name: config
        secret:
          secretName: thanos-objstore-config

由于要访问minio,同样配置了secret:thanos-objstore-config,作为volumne挂载;

  1. 部署compactor svc
# cat thanos-compactor-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: thanos-compactor
  labels:
    app: thanos-compactor
  namespace: monitoring
spec:
  selector:
    app: thanos-compactor
  ports:
  - port: 10902
    name: http

端口类型ClusterIP。

部署完成后,查看monitoring下的所有pod
thanos部署(四) -- store和compactor_第2张图片

参考:

  1. https://mp.weixin.qq.com/s/E6...
  2. https://thanos.io/tip/compone...
  3. https://mp.weixin.qq.com/s?__...

你可能感兴趣的