关于kubernetes: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

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

参考:

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

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理