关于云原生:thanos部署三-sidecar和querier

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

sidecar

  1. 创立minio的拜访配置(s3协定)
# cat thanos-storage-minio.yaml
type: s3
config:
  bucket: thanos
  endpoint: minio.minio.svc.cluster.local:9000
  access_key: minio
  secret_key: minio123
  insecure: true
  signature_version2: false

创立secret保留配置:

$ kubectl create secret generic thanos-objectstorage --from-file=thanos.yaml=thanos-storage-minio.yaml -n monitoring
  1. 批改prometheus的CRD,减少thanos的配置
# vi ../prometheus/prometheus-prometheus.yaml
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
  labels:
    prometheus: k8s
  name: k8s
  namespace: monitoring
spec:
  ...
  thanos:
    image: thanosio/thanos:v0.18.0
    objectStorageConfig:
      key: thanos.yaml
      name: thanos-objstore-config

更新CRD:

# kubectl replace -f prometheus-prometheus.yaml

Prometheus-Operator监听到CRD的批改后:

  • 为每个Prometheus Pod减少1个sidecar container;
  • 为prometheus-operated这个svc减少1个10901的grpc拜访端口;
  1. thanos应用的端口统计:
  • 10900: cluster-port;
  • 10901: grpc;
  • 10902: http;

querier

  1. 部署querier deployment
    因为querier组件须要与sidecar和store组件对接,故querier须要配置:
  • sidecar的拜访地址;
  • store的拜访地址;(该配置待store组件部署ok后再批改)
# cat thanos-querier-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: thanos-querier
  namespace: monitoring
  labels:
    app: thanos-querier
spec:
  replicas: 1
  selector:
    matchLabels:
      app: thanos-querier
  template:
    metadata:
      labels:
        app: thanos-querier
    spec:
      containers:
      - name: thanos
        image: thanosio/thanos:v0.18.0
        args:
        - "query"
        - "--log.level=debug"
        - "--query.replica-label=prometheus_replica"
        - "--store=dnssrv+prometheus-operated:10901"
        ports:
        - name: http
          containerPort: 10902
        - name: grpc
          containerPort: 10901
        - name: cluster
          containerPort: 10900

这里仅配置了sidecar的拜访地址:–store=dnssrv+prometheus-operated:10901

  1. 部署querier service

querier Service用NodePort将服务裸露进去,能够应用NodePort拜访querier WEB UI做查问;

# cat thanos-querier-svc.yaml
apiVersion: v1
kind: Service
metadata:
  annotations:
    prometheus.io/path: /metrics
    prometheus.io/port: "10902"
    prometheus.io/scrape: "true"
  name: thanos-querier
  labels:
    app: thanos-querier
  namespace: monitoring
spec:
  selector:
    app: thanos-querier
  ports:
  - port: 9090
    targetPort: http
    name: http-querier
    nodePort: 32700
  type: NodePort

裸露的NodePort=32700,拜访WEB UI如下:

拜访“store”菜单,能够看到querier对接的存储列表:sidecar已被辨认

  1. 创立querier-ServiceMonitor将其退出prometheus监控
# cat thanos-querier-serviceMonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: thanos-querier
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app: thanos-querier
  namespaceSelector:
    matchNames:
      - "monitoring"
  endpoints:
  - port: http-querier
    interval: 15s

serviceMonitor被创立后,能够在prometheus WEB UI的target列表中查看:

评论

发表回复

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

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