-
Notifications
You must be signed in to change notification settings - Fork 68
/
observatorium-logs-template-overwrites.libsonnet
159 lines (155 loc) · 5.05 KB
/
observatorium-logs-template-overwrites.libsonnet
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
// JaegerAgent sidecar shared across components, thus instantiated outside components.
local jaegerAgentSidecar = (import 'sidecars/jaeger-agent.libsonnet')({
image: '${JAEGER_AGENT_IMAGE}:${JAEGER_AGENT_IMAGE_TAG}',
collectorAddress: 'dns:///jaeger-collector-headless.${JAEGER_COLLECTOR_NAMESPACE}.svc:14250',
});
{
local replicas = {
'chunk-cache-statefulset': '${{LOKI_CHUNK_CACHE_REPLICAS}}',
'index-query-cache-statefulset': '${{LOKI_INDEX_QUERY_CACHE_REPLICAS}}',
'results-cache-statefulset': '${{LOKI_RESULTS_CACHE_REPLICAS}}',
},
lokiCaches+:: {
[name]+: {
serviceMonitor+: {
metadata+: {
labels+: {
prometheus: 'app-sre',
'app.kubernetes.io/version':: 'hidden',
},
},
spec+: { namespaceSelector+: { matchNames: ['${NAMESPACE}'] } },
},
}
for name in std.objectFieldsAll(super.lokiCaches)
if std.objectHas(super.lokiCaches[name], 'serviceMonitor')
} + {
manifests+:: {
[name]+: {
metadata+: {
annotations+: {
'ignore-check.kube-linter.io/memory-requirements': 'This is a cache, minimal memory required',
},
},
spec+: {
replicas: replicas[name],
template+: {
spec+: {
securityContext: {},
containers: [
c {
livenessProbe: {
initialDelaySeconds: 30,
tcpSocket: {
port: c.ports[0].containerPort,
},
timeoutSeconds: 5,
},
readinessProbe: {
initialDelaySeconds: 5,
tcpSocket: {
port: c.ports[0].containerPort,
},
timeoutSeconds: 1,
},
}
for c in super.containers
],
},
},
},
}
for name in std.objectFields(super.manifests)
if std.member(std.objectFields(replicas), name)
},
},
loki+:: {
serviceMonitors+:: {
[name]+: {
metadata+: {
labels+: {
prometheus: 'app-sre',
'app.kubernetes.io/version':: 'hidden',
},
},
spec+: { namespaceSelector+: { matchNames: ['${NAMESPACE}'] } },
}
for name in std.objectFields(super.serviceMonitors)
},
manifests+:: {
[name]+:
local m = super[name];
if m.kind == 'ConfigMap' && std.length(std.findSubstr('rules', name)) == 0 then
m {
metadata+: {
annotations+: {
'qontract.recycle': 'true',
},
},
}
else if m.kind == 'StatefulSet' && std.length(std.findSubstr('ingester', name)) != 0 then
m {
spec+: {
volumeClaimTemplates: [
t {
spec: {
accessModes: ['ReadWriteOnce'],
resources: {
requests: {
storage: '${LOKI_INGESTER_PVC_REQUEST}',
},
},
storageClassName: '${STORAGE_CLASS}',
},
}
for t in super.volumeClaimTemplates
],
} + jaegerAgentSidecar.spec,
}
else if m.kind == 'StatefulSet' && std.length(std.findSubstr('ruler', name)) != 0 then
m {
spec+: {
volumeClaimTemplates: [
t {
spec: {
accessModes: ['ReadWriteOnce'],
resources: {
requests: {
storage: '${LOKI_RULER_PVC_REQUEST}',
},
},
storageClassName: '${STORAGE_CLASS}',
},
}
for t in super.volumeClaimTemplates
],
} + jaegerAgentSidecar.spec,
}
else if m.kind == 'Deployment' || m.kind == 'StatefulSet' then
m {
spec+: {
template+: {
spec+: {
containers: [
c +
if std.length(std.findSubstr('query-frontend', c.name)) != 0 then
// The frontend will only return ready once a querier has connected to it.
// Because the service used for connecting the querier to the frontend only lists ready
// instances there's sequencing issue. For now, we re-use the liveness-probe path
// for the readiness-probe as a workaround.
{
readinessProbe: c.livenessProbe,
}
else {}
for c in super.containers
],
},
},
} + jaegerAgentSidecar.spec,
}
else
m
for name in std.objectFields(super.manifests)
},
},
}