diff --git a/jsonnet/kube-prometheus/main.libsonnet b/jsonnet/kube-prometheus/main.libsonnet index 462f9aeff6ba23f986c37e007e166e7c31b75f17..ddb241d823ff52995e8cfb3627c00dd294872fbe 100644 --- a/jsonnet/kube-prometheus/main.libsonnet +++ b/jsonnet/kube-prometheus/main.libsonnet @@ -9,6 +9,8 @@ local prometheusAdapter = import './components/prometheus-adapter.libsonnet'; local prometheusOperator = import './components/prometheus-operator.libsonnet'; local prometheus = import './components/prometheus.libsonnet'; +local platformPatch = (import './platforms/platforms.libsonnet').platformPatch; + { // using `values` as this is similar to helm values:: { @@ -104,6 +106,7 @@ local prometheus = import './components/prometheus.libsonnet'; kubePrometheus: { namespace: $.values.common.namespace, mixin+: { ruleLabels: $.values.common.ruleLabels }, + platform: null, }, }, @@ -124,5 +127,5 @@ local prometheus = import './components/prometheus.libsonnet'; name: $.values.kubePrometheus.namespace, }, }, - }, + } + platformPatch($.values.kubePrometheus.platform), } diff --git a/jsonnet/kube-prometheus/platforms/README.md b/jsonnet/kube-prometheus/platforms/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8edeade6915b769ac40bdf84afeb57cafdf0fedd --- /dev/null +++ b/jsonnet/kube-prometheus/platforms/README.md @@ -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', + } + } + } +``` diff --git a/jsonnet/kube-prometheus/platforms/platforms.libsonnet b/jsonnet/kube-prometheus/platforms/platforms.libsonnet new file mode 100644 index 0000000000000000000000000000000000000000..9c6f07c7ecfb9d4c53fe21c9f23412bd82b92434 --- /dev/null +++ b/jsonnet/kube-prometheus/platforms/platforms.libsonnet @@ -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 {}, +}