jsonnet: add function to apply platform patches
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
This commit is contained in:
@@ -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),
|
||||||
}
|
}
|
||||||
|
|||||||
18
jsonnet/kube-prometheus/platforms/README.md
Normal file
18
jsonnet/kube-prometheus/platforms/README.md
Normal 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',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
16
jsonnet/kube-prometheus/platforms/platforms.libsonnet
Normal file
16
jsonnet/kube-prometheus/platforms/platforms.libsonnet
Normal 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 {},
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user