From f06175bb3bc3bc0208cf750b2e9d46761ce134ca Mon Sep 17 00:00:00 2001 From: Damien Grisonnet <dgrisonn@redhat.com> Date: Wed, 31 Mar 2021 17:12:42 +0200 Subject: [PATCH] jsonnet: add function to apply platform patches Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com> --- jsonnet/kube-prometheus/main.libsonnet | 5 ++++- jsonnet/kube-prometheus/platforms/README.md | 18 ++++++++++++++++++ .../platforms/platforms.libsonnet | 16 ++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 jsonnet/kube-prometheus/platforms/README.md create mode 100644 jsonnet/kube-prometheus/platforms/platforms.libsonnet diff --git a/jsonnet/kube-prometheus/main.libsonnet b/jsonnet/kube-prometheus/main.libsonnet index 462f9aef..ddb241d8 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 00000000..8edeade6 --- /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 00000000..9c6f07c7 --- /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 {}, +} -- GitLab