Skip to content

Commit 5c2ddd6

Browse files
committed
Move around configs, use map
1 parent bc26b3e commit 5c2ddd6

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

prometheus-ksonnet/lib/config.libsonnet

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
prometheus_path: '/prometheus/',
3939
prometheus_port: 9090,
4040
prometheus_web_route_prefix: $._config.prometheus_path,
41+
prometheus_config_file: '/etc/prometheus/prometheus.yml',
4142

4243
// Alertmanager config options.
4344
alertmanager_external_hostname: 'http://alertmanager.%(namespace)s.svc.%(cluster_dns_suffix)s' % self,

prometheus-ksonnet/lib/prometheus.libsonnet

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
name:: error 'must specify name',
1414

1515
_config:: $._config,
16+
local _config = self._config,
1617

1718
local policyRule = $.rbac.v1beta1.policyRule,
1819

@@ -30,29 +31,26 @@
3031

3132
local container = $.core.v1.container,
3233

33-
prometheus_config_file:: '/etc/prometheus/prometheus.yml',
34+
prometheus_args:: {
35+
'--config.file': _config.prometheus_config_file,
36+
'--web.listen-address': _config.prometheus_port,
37+
'--web.external-url': '%(prometheus_external_hostname)s%(prometheus_path)s' % _config,
38+
'--web.enable-admin-api': true,
39+
'--web.enable-lifecycle': true,
40+
'--web.route-prefix': _config.prometheus_web_route_prefix,
41+
'--storage.tsdb.path': '/prometheus/data',
42+
'--storage.tsdb.wal-compression': true,
43+
},
3444

3545
prometheus_container::
36-
local _config = self._config;
3746

3847
container.new('prometheus', $._images.prometheus) +
3948
container.withPorts($.core.v1.containerPort.new('http-metrics', _config.prometheus_port)) +
40-
container.withArgs([
41-
'--config.file=' + self.prometheus_config_file,
42-
'--web.listen-address=:%s' % _config.prometheus_port,
43-
'--web.external-url=%(prometheus_external_hostname)s%(prometheus_path)s' % _config,
44-
'--web.enable-admin-api',
45-
'--web.enable-lifecycle',
46-
'--web.route-prefix=%s' % _config.prometheus_web_route_prefix,
47-
'--storage.tsdb.path=/prometheus/data',
48-
'--storage.tsdb.wal-compression',
49-
]) +
49+
container.withArgs($.util.mapToArgs(self.prometheus_args) +
5050
$.util.resourcesRequests('250m', '1536Mi') +
5151
$.util.resourcesLimits('500m', '2Gi'),
5252

5353
prometheus_watch_container::
54-
local _config = self._config;
55-
5654
container.new('watch', $._images.watch) +
5755
container.withArgs([
5856
'-v',
@@ -83,8 +81,6 @@
8381
$.util.configVolumeMount('%s-config' % self.name, '/etc/prometheus'),
8482

8583
prometheus_statefulset:
86-
local _config = self._config;
87-
8884
statefulset.new(self.name, 1, [
8985
self.prometheus_container + container.withVolumeMountsMixin(
9086
volumeMount.new('%s-data' % self.name, '/prometheus')
@@ -106,8 +102,6 @@
106102
local servicePort = service.mixin.spec.portsType,
107103

108104
prometheus_service:
109-
local _config = self._config;
110-
111105
$.util.serviceFor(self.prometheus_statefulset) +
112106
service.mixin.spec.withPortsMixin([
113107
servicePort.newNamed(

0 commit comments

Comments
 (0)