|
1 | 1 | local k = import 'ksonnet-util/kausal.libsonnet';
|
2 | 2 |
|
3 | 3 | {
|
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: '' }, |
7 | 8 |
|
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 | + , |
27 | 30 |
|
28 | 31 | withData(data):: { data: data },
|
29 | 32 |
|
@@ -56,8 +59,17 @@ local k = import 'ksonnet-util/kausal.libsonnet';
|
56 | 59 | + configMap.withData({
|
57 | 60 | 'httpd.conf': config,
|
58 | 61 | }),
|
| 62 | + |
59 | 63 | 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, |
61 | 73 | },
|
62 | 74 |
|
63 | 75 | metric:: {
|
|
0 commit comments