From e2dbc637646a8eeb676b2fe44af2de8703875a55 Mon Sep 17 00:00:00 2001 From: paulfantom <pawel@krupa.net.pl> Date: Tue, 19 Jan 2021 15:46:51 +0100 Subject: [PATCH] format and regenerate --- README.md | 4 ++-- docs/EKS-cni-support.md | 2 +- ...prometheus-rules-and-grafana-dashboards.md | 2 +- docs/weave-net-support.md | 4 ++-- .../addons/config-mixins.libsonnet | 20 ++++++++++++++++--- .../addons/custom-metrics.libsonnet | 2 +- .../addons/static-etcd.libsonnet | 2 +- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 49fc3077..361fa7f9 100644 --- a/README.md +++ b/README.md @@ -240,7 +240,7 @@ local kp = { ['kubernetes-' + name]: kp.kubernetesMixin[name] for name in std.objectFields(kp.kubernetesMixin) } { ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } + { ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } + -{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } + +{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } ``` And here's the [build.sh](build.sh) script (which uses `vendor/` to render all manifests in a json structure of `{filename: manifest-content}`): @@ -596,7 +596,7 @@ In order to monitor additional namespaces, the Prometheus server requires the ap ```jsonnet local kp = (import 'kube-prometheus/main.libsonnet') + { values+:: { - common+: { + common+: { namespace: 'monitoring', }, diff --git a/docs/EKS-cni-support.md b/docs/EKS-cni-support.md index 90bef138..4cb36bc9 100644 --- a/docs/EKS-cni-support.md +++ b/docs/EKS-cni-support.md @@ -10,7 +10,7 @@ You can monitor the `awscni` using kube-promethus with : local kp = (import 'kube-prometheus/main.libsonnet') + (import 'kube-prometheus/platforms/eks.libsonnet') + { values+:: { - common+: { + common+: { namespace: 'monitoring', }, }, diff --git a/docs/developing-prometheus-rules-and-grafana-dashboards.md b/docs/developing-prometheus-rules-and-grafana-dashboards.md index 514fd03e..31babf72 100644 --- a/docs/developing-prometheus-rules-and-grafana-dashboards.md +++ b/docs/developing-prometheus-rules-and-grafana-dashboards.md @@ -44,7 +44,7 @@ local kp = { ['kubernetes-' + name]: kp.kubernetesMixin[name] for name in std.objectFields(kp.kubernetesMixin) } { ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } + { ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } + -{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } + +{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } ``` ## Prometheus rules diff --git a/docs/weave-net-support.md b/docs/weave-net-support.md index 0ef65680..8766bfc8 100644 --- a/docs/weave-net-support.md +++ b/docs/weave-net-support.md @@ -18,14 +18,14 @@ Using kube-prometheus and kubectl you will be able install the following for mon [embedmd]:# (../examples/weave-net-example.jsonnet) ```jsonnet local kp = (import 'kube-prometheus/main.libsonnet') + - (import 'kube-prometheus/addons/weave-net.libsonnet') + { + (import 'kube-prometheus/addons/weave-net/weave-net.libsonnet') + { values+:: { common+: { namespace: 'monitoring', }, }, prometheus+: { - prometheusRule+: { + prometheusRuleWeaveNet+: { spec+: { groups: std.map( function(group) diff --git a/jsonnet/kube-prometheus/addons/config-mixins.libsonnet b/jsonnet/kube-prometheus/addons/config-mixins.libsonnet index ff8fd297..79f25044 100644 --- a/jsonnet/kube-prometheus/addons/config-mixins.libsonnet +++ b/jsonnet/kube-prometheus/addons/config-mixins.libsonnet @@ -1,4 +1,18 @@ -local l = import 'lib/lib.libsonnet'; +local imageName(image) = + local parts = std.split(image, '/'); + local len = std.length(parts); + if len == 3 then + // registry.com/org/image + parts[2] + else if len == 2 then + // org/image + parts[1] + else if len == 1 then + // image, ie. busybox + parts[0] + else + error 'unknown image format: ' + image; + // withImageRepository is a mixin that replaces all images prefixes by repository. eg. // quay.io/coreos/addon-resizer -> $repository/addon-resizer @@ -6,8 +20,8 @@ local l = import 'lib/lib.libsonnet'; local withImageRepository(repository) = { local oldRepos = super._config.imageRepos, local substituteRepository(image, repository) = - if repository == null then image else repository + '/' + l.imageName(image), - _config+:: { + if repository == null then image else repository + '/' + imageName(image), + values+:: { imageRepos:: { [field]: substituteRepository(oldRepos[field], repository) for field in std.objectFields(oldRepos) diff --git a/jsonnet/kube-prometheus/addons/custom-metrics.libsonnet b/jsonnet/kube-prometheus/addons/custom-metrics.libsonnet index 55e03bd7..06e9c5a0 100644 --- a/jsonnet/kube-prometheus/addons/custom-metrics.libsonnet +++ b/jsonnet/kube-prometheus/addons/custom-metrics.libsonnet @@ -78,7 +78,7 @@ }, }, - prometheusAdapter+:: { + prometheusAdapter+: { customMetricsApiService: { apiVersion: 'apiregistration.k8s.io/v1', kind: 'APIService', diff --git a/jsonnet/kube-prometheus/addons/static-etcd.libsonnet b/jsonnet/kube-prometheus/addons/static-etcd.libsonnet index d029d6c1..d49bc633 100644 --- a/jsonnet/kube-prometheus/addons/static-etcd.libsonnet +++ b/jsonnet/kube-prometheus/addons/static-etcd.libsonnet @@ -9,7 +9,7 @@ insecureSkipVerify: null, }, }, - prometheus+:: { + prometheus+: { serviceEtcd: { apiVersion: 'v1', kind: 'Service', -- GitLab