forked from thanos-io/thanos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprometheus-gcs.yaml
199 lines (194 loc) · 5.6 KB
/
prometheus-gcs.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: prometheus-gcs
labels:
app: prometheus-gcs
thanos-peer: "true"
spec:
serviceName: "prometheus"
replicas: 2
selector:
matchLabels:
app: prometheus-gcs
thanos-peer: "true"
template:
metadata:
labels:
app: prometheus-gcs
thanos-peer: "true"
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "10902"
spec:
## Commented out because Minikube has only one node, should be commented in for any production setup
# affinity:
# podAntiAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# - labelSelector:
# matchExpressions:
# - key: app
# operator: In
# values:
# - prometheus
# topologyKey: kubernetes.io/hostname
containers:
- name: prometheus
image: quay.io/prometheus/prometheus:v2.0.0
args:
- "--storage.tsdb.retention=24h"
- "--config.file=/etc/prometheus-shared/prometheus.yml"
- "--storage.tsdb.path=/var/prometheus"
- "--storage.tsdb.min-block-duration=2h"
- "--storage.tsdb.max-block-duration=2h"
- "--web.enable-lifecycle"
ports:
- name: prom-http
containerPort: 9090
volumeMounts:
- name: config-shared
mountPath: /etc/prometheus-shared
- name: data
mountPath: /var/prometheus
- name: thanos-sidecar
# Always use explicit image tags (release or master-<date>-sha) instead of ambigous `latest` or `master`.
image: improbable/thanos:v0.1.0
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /creds/gcs-credentials.json
args:
- "sidecar"
- "--log.level=debug"
- "--tsdb.path=/var/prometheus"
- "--prometheus.url=http://127.0.0.1:9090"
- "--cluster.peers=thanos-peers.default.svc.cluster.local:10900"
# NOTE: This is required to be added in GCS prior startup of this.
- "--gcs.bucket=<bucket-name>"
- "--reloader.config-file=/etc/prometheus/prometheus.yml.tmpl"
- "--reloader.config-envsubst-file=/etc/prometheus-shared/prometheus.yml"
ports:
- name: sidecar-http
containerPort: 10902
- name: grpc
containerPort: 10901
- name: cluster
containerPort: 10900
volumeMounts:
- name: data
mountPath: /var/prometheus
- name: gcs-credentials
mountPath: /creds/
- name: config-shared
mountPath: /etc/prometheus-shared
- name: config
mountPath: /etc/prometheus
volumes:
- name: config
configMap:
name: prometheus-config-gcs
- name: config-shared
emptyDir: {}
- name: data
emptyDir: {}
- name: gcs-credentials
secret:
defaultMode: 420
# NOTE: gcs-credentials secret with single file gcs-credentials.json (GCS service account) is required.
secretName: gcs-credentials
---
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config-gcs
data:
prometheus.yml.tmpl: |-
global:
external_labels:
monitor: prometheus
replica: '$(HOSTNAME)'
scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- "127.0.0.1:9090"
- job_name: kubelets
kubernetes_sd_configs:
- role: node
- job_name: kube_pods
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scheme]
action: replace
target_label: __scheme__
regex: (https?)
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
regex: (.+?)(?::\d+)?;(\d+)
replacement: ${1}:${2}
target_label: __address__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- source_labels: [__meta_kubernetes_pod_namespace]
action: replace
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: kubernetes_pod_name
# Scrapes the endpoint lists for the main Prometheus endpoints
- job_name: kube_endpoints
kubernetes_sd_configs:
- role: endpoints
relabel_configs:
- action: keep
source_labels: [__meta_kubernetes_service_label_app]
regex: prometheus
- action: replace
source_labels: [__meta_kubernetes_service_label_app]
target_label: job
- action: replace
target_label: prometheus
source_labels: [__meta_kubernetes_service_label_prometheus]
---
apiVersion: v1
kind: Service
metadata:
labels:
app: prometheus-gcs
name: prometheus-gcs
spec:
externalTrafficPolicy: Cluster
ports:
- port: 9090
protocol: TCP
targetPort: prom-http
name: http-prometheus
- port: 10902
protocol: TCP
targetPort: sidecar-http
name: http-sidecar-metrics
selector:
app: prometheus-gcs
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}
---
apiVersion: v1
kind: Service
metadata:
name: thanos-peers
spec:
type: ClusterIP
clusterIP: None
ports:
- name: cluster
port: 10900
targetPort: cluster
selector:
# Useful endpoint for gathering all thanos components for common gossip cluster.
thanos-peer: "true"