-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathmetal3-kube-prometheus.jsonnet
214 lines (211 loc) · 7.17 KB
/
metal3-kube-prometheus.jsonnet
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// addArgs adds the args to the container with matching name
local addArgs(args, name, containers) = std.map(
function(c) if c.name == name then
c {
args+: args,
}
else c,
containers,
);
local kp =
(import 'kube-prometheus/main.libsonnet') +
{
values+:: {
common+: {
namespace: 'monitoring',
},
grafana+: {
dashboards+:: { // use this method to import your dashboards to Grafana
'jobs.json': (import 'jobs.json'),
},
rawDashboards+:: {
'jobs.json': (importstr 'jobs.json'),
},
config+: {
sections: {
'auth.anonymous': {
enabled: true,
org_role: 'Viewer',
},
'auth': {
disable_login_form: true,
},
'auth.basic': {
enabled: false,
},
'security': {
disable_gravatar: true,
},
},
},
},
},
// Add toleration and node selector to all components
prometheus+: {
prometheus+: {
spec+: {
tolerations: [
{
key: "node-role.kubernetes.io/infra",
operator: "Exists",
effect: "NoSchedule",
},
],
nodeSelector+: {
'node-role.kubernetes.io/infra': "",
},
// If a value isn't specified for 'retention', then by default the '--storage.tsdb.retention=24h' arg will be passed to prometheus by prometheus-operator.
// The possible values for a prometheus <duration> are:
// * https://github.com/prometheus/common/blob/c7de230/model/time.go#L178 specifies "^([0-9]+)(y|w|d|h|m|s|ms)$" (years weeks days hours minutes seconds milliseconds)
retention: '30d',
// Reference info: https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/storage.md
// By default (if the following 'storage.volumeClaimTemplate' isn't created), prometheus will be created with an EmptyDir for the 'prometheus-k8s-db' volume (for the prom tsdb).
// This 'storage.volumeClaimTemplate' causes the following to be automatically created (via dynamic provisioning) for each prometheus pod:
// * PersistentVolumeClaim (and a corresponding PersistentVolume)
// * the actual volume (per the StorageClassName specified below)
storage: {
volumeClaimTemplate: {
apiVersion: 'v1',
kind: 'PersistentVolumeClaim',
spec: {
accessModes: ['ReadWriteOnce'],
resources: { requests: { storage: '100Gi' } },
storageClassName: 'csi-cinderplugin',
},
},
},
}
},
},
prometheusOperator+: {
deployment+: {
spec+: {
template+: {
spec+: {
tolerations: [
{
key: "node-role.kubernetes.io/infra",
operator: "Exists",
effect: "NoSchedule",
},
],
nodeSelector+: {
"node-role.kubernetes.io/infra": "",
},
},
},
}
},
},
prometheusAdapter+: {
deployment+: {
spec+: {
template+: {
spec+: {
tolerations: [
{
key: "node-role.kubernetes.io/infra",
operator: "Exists",
effect: "NoSchedule",
},
],
nodeSelector+: {
"node-role.kubernetes.io/infra": "",
},
},
},
}
},
},
alertmanager+: {
alertmanager+: {
spec+: {
tolerations: [
{
key: "node-role.kubernetes.io/infra",
operator: "Exists",
effect: "NoSchedule",
},
],
nodeSelector+: {
"node-role.kubernetes.io/infra": "",
},
},
},
},
grafana+: {
deployment+: {
spec+: {
template+: {
spec+: {
tolerations: [
{
key: "node-role.kubernetes.io/infra",
operator: "Exists",
effect: "NoSchedule",
},
],
nodeSelector+: {
"node-role.kubernetes.io/infra": "",
},
},
},
}
},
},
kubeStateMetrics+: {
deployment+: {
spec+: {
template+: {
spec+: {
tolerations: [
{
key: "node-role.kubernetes.io/infra",
operator: "Exists",
effect: "NoSchedule",
},
],
nodeSelector+: {
"node-role.kubernetes.io/infra": "",
},
// Add allowed labels. We need these labels to keep track of what prowjob each pod belongs to
containers: addArgs(
['--metric-labels-allowlist=pods=[' +
'app.kubernetes.io/name,' +
'app.kubernetes.io/component,' +
'app.kubernetes.io/instance,' +
'prow.k8s.io/id,' +
'prow.k8s.io/refs.repo,' +
'prow.k8s.io/type,' +
'prow.k8s.io/job,' +
'prow.k8s.io/refs.org],' +
'deployments=[' +
'app.kubernetes.io/name,' +
'app.kubernetes.io/component,' +
'app.kubernetes.io/instance]'
],
'kube-state-metrics',
super.containers
),
},
},
}
},
},
};
{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } +
{ 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) }
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }