本篇thanos部署是基于prometheus-operator,prometheus-operator为thanos提供了在CRD和controller上的反对。
store组件
- 部署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的办法;
- 部署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
- 将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
- 查看querier UI确认store增加OK
compactor组件
- 部署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挂载;
- 部署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
参考:
- https://mp.weixin.qq.com/s/E6…
- https://thanos.io/tip/compone…
- https://mp.weixin.qq.com/s?__…
发表回复