jsonnet: add function to apply platform patches

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
This commit is contained in:
Damien Grisonnet
2021-03-31 17:12:42 +02:00
parent ea12911e4f
commit f06175bb3b
3 changed files with 38 additions and 1 deletions

View File

@@ -9,6 +9,8 @@ local prometheusAdapter = import './components/prometheus-adapter.libsonnet';
local prometheusOperator = import './components/prometheus-operator.libsonnet'; local prometheusOperator = import './components/prometheus-operator.libsonnet';
local prometheus = import './components/prometheus.libsonnet'; local prometheus = import './components/prometheus.libsonnet';
local platformPatch = (import './platforms/platforms.libsonnet').platformPatch;
{ {
// using `values` as this is similar to helm // using `values` as this is similar to helm
values:: { values:: {
@@ -104,6 +106,7 @@ local prometheus = import './components/prometheus.libsonnet';
kubePrometheus: { kubePrometheus: {
namespace: $.values.common.namespace, namespace: $.values.common.namespace,
mixin+: { ruleLabels: $.values.common.ruleLabels }, mixin+: { ruleLabels: $.values.common.ruleLabels },
platform: null,
}, },
}, },
@@ -124,5 +127,5 @@ local prometheus = import './components/prometheus.libsonnet';
name: $.values.kubePrometheus.namespace, name: $.values.kubePrometheus.namespace,
}, },
}, },
}, } + platformPatch($.values.kubePrometheus.platform),
} }

View File

@@ -0,0 +1,18 @@
# Adding a new platform specific configuration
Adding a new platform specific configuration requires to update the
[platforms.jsonnet](./platform.jsonnet) file by adding the platform to the list
of existing ones.
This allow configuring the new platform in the following way:
```jsonnet
(import 'kube-prometheus/main.libsonnet') +
{
values+:: {
kubePrometheus+: {
platform: 'example-platform',
}
}
}
```

View File

@@ -0,0 +1,16 @@
local platforms = {
aws: import './aws.libsonnet',
bootkube: import './bootkube.libsonnet',
gke: import './gke.libsonnet',
eks: import './eks.libsonnet',
kops: import './kops.libsonnet',
kops_coredns: (import './kops.libsonnet') + (import './kops-coredns.libsonnet'),
kubeadm: import './kubeadm.libsonnet',
kubespray: import './kubespray.libsonnet',
};
{
// platformPatch returns the platform specific patch associated to the given
// platform.
platformPatch(p): if p != null && std.objectHas(platforms, p) then platforms[p] else {},
}