Skip to content

Commit 4e4bcb7

Browse files
committed
First pass at HA statefulset
1 parent 21b638f commit 4e4bcb7

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
prometheus_config_0: $.prometheus_config,
3+
prometheus_config_1: $.prometheus_config,
4+
5+
prometheusAlerts_0: $.prometheusAlerts,
6+
prometheusAlerts_1: $.prometheusAlerts,
7+
8+
prometheusRules_0: $.prometheusRules,
9+
prometheusRules_1: $.prometheusRules,
10+
11+
prometheus+:: {
12+
local configMap = $.core.v1.configMap,
13+
14+
prometheus_config_map:: {},
15+
16+
prometheus_config_maps: [{
17+
configMap.new('%s-config-0' % self.name) +
18+
configMap.withData({
19+
'prometheus.yml': $.util.manifestYaml($.prometheus_config_0),
20+
'alerts.rules': $.util.manifestYaml($.prometheusAlerts_0),
21+
'recording.rules': $.util.manifestYaml($.prometheusRules_0),
22+
}),
23+
configMap.new('%s-config-1' % self.name) +
24+
configMap.withData({
25+
'prometheus.yml': $.util.manifestYaml($.prometheus_config_1),
26+
'alerts.rules': $.util.manifestYaml($.prometheusAlerts_1),
27+
'recording.rules': $.util.manifestYaml($.prometheusRules_1),
28+
}),
29+
]},
30+
31+
prometheus_config_mount:: {},
32+
33+
prometheus_init_container::
34+
container.new('prometheus-init', 'busybox') +
35+
container.withCommand(["ln", "-s", "/etc/$HOSTNAME", "/etc/prometheus"]),
36+
37+
prometheus_statefulset:
38+
$.util.configVolumeMount('%s-config-0' % self.name, '/etc/prometheus-0') +
39+
$.util.configVolumeMount('%s-config-1' % self.name, '/etc/prometheus-1') +
40+
statefulset.mixin.spec.template.spec.withInitContainers(self.prometheus_init_container) +
41+
statefulset.mixin.spec.withReplicas(2),
42+
}

prometheus-ksonnet/lib/prometheus.libsonnet

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
local statefulset = $.apps.v1.statefulSet,
7878
local volumeMount = $.core.v1.volumeMount,
7979

80+
prometheus_config_mount::
81+
$.util.configVolumeMount('%s-config' % self.name, '/etc/prometheus'),
82+
8083
prometheus_statefulset:
8184
local _config = self._config;
8285

@@ -86,7 +89,7 @@
8689
),
8790
self.prometheus_watch_container,
8891
], self.prometheus_pvc) +
89-
$.util.configVolumeMount('%s-config' % self.name, '/etc/prometheus') +
92+
self.prometheus_config_mount +
9093
statefulset.mixin.spec.withServiceName('prometheus') +
9194
statefulset.mixin.spec.template.metadata.withAnnotations({
9295
'prometheus.io.path': '%smetrics' % _config.prometheus_web_route_prefix,

0 commit comments

Comments
 (0)