介绍
-
https://github.com/particuleio/teks/tree/main/terragrunt/live/thanos
-
https://github.com/particuleio/terraform-kubernetes-addons/tree/main/modules/aws
Kubernetes技术栈
-
Prometheus:收集度量标准
-
告警管理器:根据指标查询向各种提供者发送警报
-
Grafana:可视化豪华仪表板
Thanos,它来了
-
Thanos Store
-
Thanos Sidecar
-
Thanos Query
多集群架构
-
一个观察者集群[3]
-
一个被观察集群[4]
.
├──env_tags.yaml
├──eu-west-1
│├──clusters
││└──observer
││├──eks
│││├──kubeconfig
│││└──terragrunt.hcl
││├──eks-addons
│││└──terragrunt.hcl
││└──vpc
││└──terragrunt.hcl
│└──region_values.yaml
└──eu-west-3
├──clusters
│└──observee
│├──cluster_values.yaml
│├──eks
││├──kubeconfig
││└──terragrunt.hcl
│├──eks-addons
││└──terragrunt.hcl
│└──vpc
│└──terragrunt.hcl
└──region_values.yaml
-
Grafana启用
-
Thanos边车上传到特定的桶
kube-prometheus-stack={
enabled= true
allowed_cidrs=dependency.vpc.outputs.private_subnets_cidr_blocks
thanos_sidecar_enabled= true
thanos_bucket_force_destroy= true
extra_values=<<-EXTRA_VALUES
grafana:
deploymentStrategy:
type:Recreate
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class:nginx
cert-manager.io/cluster-issuer: "letsencrypt"
hosts:
-grafana. ${local.default_domain_suffix}
tls:
-secretName:grafana. ${local.default_domain_suffix}
hosts:
-grafana. ${local.default_domain_suffix}
persistence:
enabled: true
storageClassName:ebs-sc
accessModes:
-ReadWriteOnce
size:1Gi
prometheus:
prometheusSpec:
replicas:1
retention:2d
retentionSize: "10GB"
ruleSelectorNilUsesHelmValues: false
serviceMonitorSelectorNilUsesHelmValues: false
podMonitorSelectorNilUsesHelmValues: false
storageSpec:
volumeClaimTemplate:
spec:
storageClassName:ebs-sc
accessModes:[ "ReadWriteOnce"]
resources:
requests:
storage:10Gi
EXTRA_VALUES
-
这个CA将被进入sidecar的被观察集群所信任
-
为Thanos querier组件生成TLS证书,这些组件将查询被观察集群
-
Thanos组件全部部署完成
-
查询前端,作为Grafana的数据源端点
-
存储网关用于查询观察者桶
-
Query将对存储网关和其他查询器执行查询
-
配置了TLS的Thanos查询器对每个被观察集群进行查询
thanos-tls-querier={
"observee"={
enabled= true
default_global_requests= true
default_global_limits= false
stores=[
"thanos-sidecar. ${local.default_domain_suffix}:443"
]
}
}
thanos-storegateway={
"observee"={
enabled= true
default_global_requests= true
default_global_limits= false
bucket= "thanos-store-pio-thanos-observee"
region= "eu-west-3"
}
-
Thanos这边就是上传给观察者特定的桶
-
Thanos边车与TLS客户端认证的入口对象一起发布,并信任观察者集群CA
kube-prometheus-stack={
enabled= true
allowed_cidrs=dependency.vpc.outputs.private_subnets_cidr_blocks
thanos_sidecar_enabled= true
thanos_bucket_force_destroy= true
extra_values=<<-EXTRA_VALUES
grafana:
enabled: false
prometheus:
thanosIngress:
enabled: true
ingressClassName:nginx
annotations:
cert-manager.io/cluster-issuer: "letsencrypt"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
nginx.ingress.kubernetes.io/auth-tls-verify-client: "on"
nginx.ingress.kubernetes.io/auth-tls-secret: "monitoring/thanos-ca"
hosts:
-thanos-sidecar. ${local.default_domain_suffix}
paths:
-/
tls:
-secretName:thanos-sidecar. ${local.default_domain_suffix}
hosts:
-thanos-sidecar. ${local.default_domain_suffix}
prometheusSpec:
replicas:1
retention:2d
retentionSize: "6GB"
ruleSelectorNilUsesHelmValues: false
serviceMonitorSelectorNilUsesHelmValues: false
podMonitorSelectorNilUsesHelmValues: false
storageSpec:
volumeClaimTemplate:
spec:
storageClassName:ebs-sc
accessModes:[ "ReadWriteOnce"]
resources:
requests:
storage:10Gi
EXTRA_VALUES
-
Thanos压缩器来管理这个特定集群的下采样
thanos={
enabled= true
bucket_force_destroy= true
trusted_ca_content=dependency.thanos-ca.outputs.thanos_ca
extra_values=<<-EXTRA_VALUES
compactor:
retentionResolution5m:90d
query:
enabled: false
queryFrontend:
enabled: false
storegateway:
enabled: false
EXTRA_VALUES
}
再深入一点
kubectl-nmonitoringgetpods
NAMEREADYSTATUSRESTARTSAGE
alertmanager-kube-prometheus-stack-alertmanager-02/2Running0120m
kube-prometheus-stack-grafana-c8768466b-rd8wm2/2Running0120m
kube-prometheus-stack-kube-state-metrics-5cf575d8f8-x59rd1/1Running0120m
kube-prometheus-stack-operator-6856b9bb58-hdrb21/1Running0119m
kube-prometheus-stack-prometheus-node-exporter-8hvmv1/1Running0117m
kube-prometheus-stack-prometheus-node-exporter-cwlfd1/1Running0120m
kube-prometheus-stack-prometheus-node-exporter-rsss51/1Running0120m
kube-prometheus-stack-prometheus-node-exporter-rzgr91/1Running0120m
prometheus-kube-prometheus-stack-prometheus-03/3Running1120m
thanos-compactor-74784bd59d-vmvps1/1Running0119m
thanos-query-7c74db546c-d7bp81/1Running012m
thanos-query-7c74db546c-ndnx21/1Running012m
thanos-query-frontend-5cbcb65b57-5sx8z1/1Running0119m
thanos-query-frontend-5cbcb65b57-qjhxg1/1Running0119m
thanos-storegateway-01/1Running0119m
thanos-storegateway-11/1Running0118m
thanos-storegateway-observee-storegateway-01/1Running012m
thanos-storegateway-observee-storegateway-11/1Running011m
thanos-tls-querier-observee-query-dfb9f79f9-4str81/1Running029m
thanos-tls-querier-observee-query-dfb9f79f9-xsq241/1Running029m
kubectl-nmonitoringgetingress
NAMECLASSHOSTSADDRESSPORTSAGE
kube-prometheus-stack-grafana<none>grafana.thanos.teks-tg.clusterfrak-dynamics.iok8s-ingressn-ingressn-afa0a48374-f507283b6cd101c5.elb.eu-west-1.amazonaws.com80,443123m
kubectl-nmonitoringgetpods
NAMEREADYSTATUSRESTARTSAGE
alertmanager-kube-prometheus-stack-alertmanager-02/2Running039m
kube-prometheus-stack-kube-state-metrics-5cf575d8f8-ct2921/1Running039m
kube-prometheus-stack-operator-6856b9bb58-4cngc1/1Running039m
kube-prometheus-stack-prometheus-node-exporter-bs4wp1/1Running039m
kube-prometheus-stack-prometheus-node-exporter-c57ss1/1Running039m
kube-prometheus-stack-prometheus-node-exporter-cp5ch1/1Running039m
kube-prometheus-stack-prometheus-node-exporter-tnqvq1/1Running039m
kube-prometheus-stack-prometheus-node-exporter-z2p491/1Running039m
kube-prometheus-stack-prometheus-node-exporter-zzqp71/1Running039m
prometheus-kube-prometheus-stack-prometheus-03/3Running139m
thanos-compactor-7576dcbcfc-6pd4v1/1Running038m
kubectl-nmonitoringgetingress
NAMECLASSHOSTSADDRESSPORTSAGE
kube-prometheus-stack-thanos-gatewaynginxthanos-sidecar.thanos.teks-tg.clusterfrak-dynamics.iok8s-ingressn-ingressn-95903f6102-d2ce9013ac068b9e.elb.eu-west-3.amazonaws.com80,44340m
k-nmonitoringlogs-fthanos-tls-querier-observee-query-687dd88ff5-nzpdh
level=infots=2021-02-23T15:37:35.692346206Z caller=storeset.go:387component=storesetmsg= "addingnewstoreAPItoquerystoreset"address=thanos-sidecar.thanos.teks-tg.clusterfrak-dynamics.io:443extLset= "{cluster=\"pio-thanos-observee\",prometheus=\"monitoring/kube-prometheus-stack-prometheus\",prometheus_replica=\"prometheus-kube-prometheus-stack-prometheus-0\"}"
kubectl-nmonitoringport-forwardthanos-tls-querier-observee-query-687dd88ff5-nzpdh10902
kubectl-nmonitoringport-forwardthanos-query-7c74db546c-d7bp810902
-
观察者把本地Thanos聚集
-
我们的存储网关(一个用于远程观测者集群,一个用于本地观测者集群)
-
本地TLS查询器,它可以查询被观察的sidecar
在Grafana可视化
总结
-
http://www.zzvips.com/uploads/allimg/6283888
https://github.com/particuleio/teks
https://github.com/particuleio/teks/tree/main/terragrunt/live/thanos/eu-west-1/clusters/observer
https://github.com/particuleio/teks/tree/main/terragrunt/live/thanos/eu-west-3/clusters/observee