Skip to content

Commit 8948a8a

Browse files
authored
fix!(static-exporter): make withHttpConfig the default (#1406)
* fix!(static-exporter): make withHttpConfig the default * fix: add function to remove httpConfig * fix: only hide httpdConfig * fix: different approach
1 parent d2fe0ae commit 8948a8a

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

static-exporter/main.libsonnet

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
local k = import 'ksonnet-util/kausal.libsonnet';
22

33
{
4-
new(name, image='httpd:2.4-alpine'):: {
5-
name:: name,
6-
data:: { metrics: '' },
4+
new(name, image='httpd:2.4-alpine')::
5+
{
6+
name:: name,
7+
data:: { metrics: '' },
78

8-
local configMap = k.core.v1.configMap,
9-
configmap:
10-
configMap.new(name, self.data),
11-
12-
local container = k.core.v1.container,
13-
container::
14-
container.new('static-exporter', image)
15-
+ container.withPorts([
16-
k.core.v1.containerPort.newNamed(name='http-metrics', containerPort=80),
17-
])
18-
+ k.util.resourcesRequests('10m', '10Mi')
19-
,
20-
21-
local deployment = k.apps.v1.deployment,
22-
local volumeMount = k.core.v1.volumeMount,
23-
deployment:
24-
deployment.new(name, replicas=1, containers=[self.container])
25-
+ k.util.configMapVolumeMount(self.configmap, '/usr/local/apache2/htdocs'),
26-
},
9+
local configMap = k.core.v1.configMap,
10+
configmap:
11+
configMap.new(name, self.data),
12+
13+
local container = k.core.v1.container,
14+
container::
15+
container.new('static-exporter', image)
16+
+ container.withPorts([
17+
k.core.v1.containerPort.newNamed(name='http-metrics', containerPort=80),
18+
])
19+
+ k.util.resourcesRequests('10m', '10Mi')
20+
,
21+
22+
local deployment = k.apps.v1.deployment,
23+
local volumeMount = k.core.v1.volumeMount,
24+
deployment:
25+
deployment.new(name, replicas=1, containers=[self.container])
26+
+ k.util.configMapVolumeMount(self.configmap, '/usr/local/apache2/htdocs'),
27+
}
28+
+ self.withHttpConfig()
29+
,
2730

2831
withData(data):: { data: data },
2932

@@ -56,8 +59,17 @@ local k = import 'ksonnet-util/kausal.libsonnet';
5659
+ configMap.withData({
5760
'httpd.conf': config,
5861
}),
62+
5963
deployment+:
60-
k.util.configMapVolumeMount(self.httpdConfig, '/usr/local/apache2/conf/httpd.conf', volumeMount.withSubPath('httpd.conf')),
64+
if std.objectHas(self, 'httpdConfig')
65+
then k.util.configMapVolumeMount(self.httpdConfig, '/usr/local/apache2/conf/httpd.conf', volumeMount.withSubPath('httpd.conf'))
66+
else {},
67+
},
68+
69+
withoutHttpConfig():: {
70+
assert std.trace('DEPRECATION WARNING: running static-exporter without HttpConfig will make it unable for Prometheus 3.x to scrape it.', true),
71+
// by hiding this field, std.objectHas in the conditional above will not find the key
72+
httpdConfig:: super.httpdConfig,
6173
},
6274

6375
metric:: {

0 commit comments

Comments
 (0)