-
Notifications
You must be signed in to change notification settings - Fork 6
/
pushgateway.libsonnet
86 lines (75 loc) · 3.09 KB
/
pushgateway.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
local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
{
_config+:: {
namespace: 'pushgateway',
versions+:: {
pushgateway: 'v0.8.0',
},
imageRepos+:: {
pushgateway: 'prom/pushgateway',
},
pushgateway+:: {
name: "prometheus-pushgateway",
port: 9091,
labels: { app: $._config.pushgateway.name},
cpu: "50m",
memory: "100Mi"
}
},
pushgateway+:: {
deployment:
local deployment = k.apps.v1beta2.deployment;
local container = deployment.mixin.spec.template.spec.containersType;
local containerPort = container.portsType;
local podSelector = deployment.mixin.spec.template.spec.selectorType;
local c =
container.new('pushgateway', $._config.imageRepos.pushgateway + ':' + $._config.versions.pushgateway) +
container.withPorts(containerPort.newNamed($._config.pushgateway.port, 'metrics')) +
container.mixin.resources.withRequests({ cpu: $._config.pushgateway.cpu, memory: $._config.pushgateway.memory }) +
container.mixin.resources.withLimits({ cpu: $._config.pushgateway.cpu, memory: $._config.pushgateway.memory }) +
container.mixin.livenessProbe.withInitialDelaySeconds(10) +
container.mixin.livenessProbe.withTimeoutSeconds(10)+
container.mixin.livenessProbe.httpGet.withPath("/#/status") +
container.mixin.livenessProbe.httpGet.withPort($._config.pushgateway.port) +
container.mixin.readinessProbe.withInitialDelaySeconds(10) +
container.mixin.readinessProbe.withTimeoutSeconds(10)+
container.mixin.readinessProbe.httpGet.withPath("/#/status") +
container.mixin.readinessProbe.httpGet.withPort($._config.pushgateway.port);
deployment.new($._config.pushgateway.name, 1, c, $._config.pushgateway.labels) +
deployment.mixin.metadata.withNamespace($._config.namespace) +
deployment.mixin.metadata.withLabels($._config.pushgateway.labels) +
deployment.mixin.spec.selector.withMatchLabels($._config.pushgateway.labels),
service:
local service = k.core.v1.service;
local servicePort = k.core.v1.service.mixin.spec.portsType;
local pushgatewayPort = servicePort.newNamed('http', $._config.pushgateway.port, 'http');
service.new($._config.pushgateway.name, $.pushgateway.deployment.spec.selector.matchLabels, pushgatewayPort) +
service.mixin.metadata.withNamespace($._config.namespace) +
service.mixin.metadata.withLabels($._config.pushgateway.labels) +
service.mixin.spec.withType('ClusterIP'),
serviceMonitor:
{
apiVersion: 'monitoring.coreos.com/v1',
kind: 'ServiceMonitor',
metadata: {
name: $._config.pushgateway.name,
namespace: $._config.namespace,
labels: {
'prometheus': 'k8s',
},
},
spec: {
jobLabel: 'k8s-app',
selector: {
matchLabels: $._config.pushgateway.labels,
},
endpoints: [
{
port: 'http',
honorLabels: true,
},
],
},
},
},
}