From 5a18c7e1cf8431c029768c7012d1bf09d47f634a Mon Sep 17 00:00:00 2001 From: WrenIX Date: Thu, 26 Oct 2023 00:02:52 +0200 Subject: [PATCH] feat(monitoring): init monitoring chart --- README.md.gotmpl | 16 +++++ monitoring/.helmignore | 23 +++++++ monitoring/Chart.yaml | 6 ++ monitoring/README.md | 37 +++++++++++ monitoring/templates/probe.yaml | 31 +++++++++ monitoring/templates/scrape-config.yaml | 59 ++++++++++++++++++ monitoring/values.yaml | 83 +++++++++++++++++++++++++ publish.sh | 3 +- 8 files changed, 256 insertions(+), 2 deletions(-) create mode 100644 README.md.gotmpl create mode 100644 monitoring/.helmignore create mode 100644 monitoring/Chart.yaml create mode 100644 monitoring/README.md create mode 100644 monitoring/templates/probe.yaml create mode 100644 monitoring/templates/scrape-config.yaml create mode 100644 monitoring/values.yaml diff --git a/README.md.gotmpl b/README.md.gotmpl new file mode 100644 index 0000000..9174c35 --- /dev/null +++ b/README.md.gotmpl @@ -0,0 +1,16 @@ +{{ template "chart.header" . }} +{{ template "chart.deprecationWarning" . }} + +{{ template "chart.badgesSection" . }} + +{{ template "chart.description" . }} + +{{ template "chart.homepageLine" . }} + +{{ template "chart.maintainersSection" . }} + +{{ template "chart.sourcesSection" . }} + +{{ template "chart.requirementsSection" . }} + +{{ template "chart.valuesSection" . }} diff --git a/monitoring/.helmignore b/monitoring/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/monitoring/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/monitoring/Chart.yaml b/monitoring/Chart.yaml new file mode 100644 index 0000000..cdf6940 --- /dev/null +++ b/monitoring/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: monitoring +description: Deploy helper for probes and scrapeconfig of prometheus-operator +type: application + +version: 0.1.0 diff --git a/monitoring/README.md b/monitoring/README.md new file mode 100644 index 0000000..8fe0f78 --- /dev/null +++ b/monitoring/README.md @@ -0,0 +1,37 @@ +# monitoring + +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) + +Deploy helper for probes and scrapeconfig of prometheus-operator + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| prober | list | `[{"name":"local","spec":{"path":"/probe","url":"prometheus-blackbox-exporter:9115"}}]` | prober for each the following probes are created (multiside probes) | +| prober[0].name | string | `"local"` | name of prober | +| prober[0].spec | object | `{"path":"/probe","url":"prometheus-blackbox-exporter:9115"}` | spec of prober (like url, path, scheme ...) | +| probes[0].groups | object | `{"framasoft":["framasoft.org","degooglisons-internet.org","framapiaf.org","framatube.org"]}` | groups with targets | +| probes[0].ipv4 | bool | `true` | setup one for ipv4 (see module and his suffix) | +| probes[0].ipv6 | bool | `true` | setup one for ipv6 (see module and his suffix) | +| probes[0].module | string | `"http_2xx"` | probe module (suffix with _ipv4 and ipv6 if enabled) | +| probes[0].name | string | `"http"` | name of probe | +| probes[1].groups | object | `{"digitalcourage":["digitalcourage.de","nuudel.digitalcourage.de","digitalcourage.social"]}` | groups with targets | +| probes[1].ipv4 | bool | `true` | setup one for ipv4 (see module and his suffix) | +| probes[1].ipv6 | bool | `false` | setup one for ipv6 (see module and his suffix) | +| probes[1].module | string | `"http_2xx"` | probe module (suffix with _ipv4 and ipv6 if enabled) | +| probes[1].name | string | `"http-ipv4"` | name of probe | +| prometheus.probe.labels | object | `{"prometheus":"default"}` | labels on Probe | +| prometheus.scrape.labels | object | `{"prometheus":"default"}` | labels on ScrapeConfig | +| scrapes[0].groups | object | `{"de":["ber.de.local:9100","fra.de.local:9100","ham.de.local:9100"],"ie":["dub.ie.local:9100","ork.ie.local:9100"]}` | groups with targets | +| scrapes[0].name | string | `"nodes"` | name of scrape | +| scrapes[1].auth.password | string | `nil` | basic auth password | +| scrapes[1].auth.token | string | `nil` | bearer token | +| scrapes[1].auth.username | string | `nil` | basic auth username | +| scrapes[1].groups | object | `{"de":["fra.de.s3.local:9000","ham.de.s3.local:9000"],"ie":["dub.ie.s3.local:9000"]}` | groups with targets | +| scrapes[1].metricsPath | string | `"/minio/v2/metrics/node"` | metric path on scrape | +| scrapes[1].name | string | `"minio"` | name of scrape | +| scrapes[1].scheme | string | `"http"` | schema on scrape | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.11.2](https://github.com/norwoodj/helm-docs/releases/v1.11.2) diff --git a/monitoring/templates/probe.yaml b/monitoring/templates/probe.yaml new file mode 100644 index 0000000..4636d78 --- /dev/null +++ b/monitoring/templates/probe.yaml @@ -0,0 +1,31 @@ +{{- range $prober := $.Values.prober }} +{{- range $probe := $.Values.probes }} +{{- range $groupName, $group := $probe.groups }} +{{- $proto := "ipv4" }} +{{- range $proto := (list "ipv4" "ipv6") }} +{{- if (get $probe $proto) }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: Probe +metadata: + name: {{ $probe.name }}-{{ $groupName }}-{{ $proto }}-{{ $prober.name }} + labels: + {{- toYaml $.Values.prometheus.probe.labels | nindent 4 }} +spec: + jobName: "blackbox-{{ $probe.name }}-{{ $proto }}" + prober: + {{- toYaml $prober.spec | nindent 4}} + module: "{{ $probe.module }}_{{ $proto }}" + targets: + staticConfig: + labels: + group: {{ $groupName }} + probe: {{ $probe.name }} + prober: {{ $prober.name }} + static: + {{- toYaml $group | nindent 8 }} +{{- end }} +{{- end }} +{{- end }} +{{- end }} +{{- end }} diff --git a/monitoring/templates/scrape-config.yaml b/monitoring/templates/scrape-config.yaml new file mode 100644 index 0000000..15aea0f --- /dev/null +++ b/monitoring/templates/scrape-config.yaml @@ -0,0 +1,59 @@ +{{- range $scrape := $.Values.scrapes }} +{{ $secretName := printf "monitoring-scrape-%s" $scrape.name }} +{{- with $scrape.auth }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ $secretName }} +data: + {{- with .token }} + token: {{ . | b64enc }} + {{- end }} + {{- with .username }} + username: {{ . | b64enc }} + {{- end }} + {{- with .password }} + password: {{ . | b64enc }} + {{- end }} +{{- end }} +--- +apiVersion: monitoring.coreos.com/v1alpha1 +kind: ScrapeConfig +metadata: + name: monitoring-{{ $scrape.name }} + labels: + {{- toYaml $.Values.prometheus.scrape.labels | nindent 4 }} +spec: + {{- with $scrape.scheme }} + scheme: {{ . | quote }} + {{- end }} + {{- with $scrape.metricsPath }} + metricsPath: {{ . | quote }} + {{- end }} + {{- if $scrape.auth }} + {{- if $scrape.auth.token }} + authorization: + type: "Bearer" + credentials: + name: {{ $secretName }} + key: token + {{- else }} + basicAuth: + username: + name: {{ $secretName }} + key: username + password: + name: {{ $secretName }} + key: password + {{- end }} + {{- end }} + staticConfigs: + {{- range $groupName, $group := $scrape.groups }} + - labels: + group: {{ $groupName }} + scrape: {{ $scrape.name }} + targets: + {{- toYaml $group | nindent 8 }} + {{- end }} +{{- end }} diff --git a/monitoring/values.yaml b/monitoring/values.yaml new file mode 100644 index 0000000..29698ad --- /dev/null +++ b/monitoring/values.yaml @@ -0,0 +1,83 @@ +prometheus: + scrape: + # -- labels on ScrapeConfig + labels: + prometheus: "default" + probe: + # -- labels on Probe + labels: + prometheus: "default" + +scrapes: + - # -- name of scrape + name: nodes + # -- groups with targets + groups: + de: + - "ber.de.local:9100" + - "fra.de.local:9100" + - "ham.de.local:9100" + ie: + - "dub.ie.local:9100" + - "ork.ie.local:9100" + - # -- name of scrape + name: minio + # -- metric path on scrape + metricsPath: /minio/v2/metrics/node + # -- schema on scrape + scheme: http + auth: + # -- basic auth username + username: + # -- basic auth password + password: + # -- bearer token + token: + # -- groups with targets + groups: + de: + - "fra.de.s3.local:9000" + - "ham.de.s3.local:9000" + ie: + - "dub.ie.s3.local:9000" + +# -- prober for each the following probes are created (multiside probes) +prober: + - # -- name of prober + name: "local" + # -- spec of prober (like url, path, scheme ...) + spec: + url: "prometheus-blackbox-exporter:9115" + path: "/probe" + +probes: + - # -- probe module (suffix with _ipv4 and ipv6 if enabled) + module: http_2xx + # -- name of probe + name: http + # -- setup one for ipv4 (see module and his suffix) + ipv4: true + # -- setup one for ipv6 (see module and his suffix) + ipv6: true + # -- groups with targets + groups: + framasoft: + - framasoft.org + - degooglisons-internet.org + - framapiaf.org + - framatube.org + + - # -- probe module (suffix with _ipv4 and ipv6 if enabled) + module: http_2xx + # -- name of probe + name: http-ipv4 + # -- setup one for ipv4 (see module and his suffix) + ipv4: true + # -- setup one for ipv6 (see module and his suffix) + ipv6: false + # -- groups with targets + groups: + digitalcourage: + - digitalcourage.de + - nuudel.digitalcourage.de + - digitalcourage.social \ No newline at end of file diff --git a/publish.sh b/publish.sh index da2e3c1..6c786b4 100755 --- a/publish.sh +++ b/publish.sh @@ -1,7 +1,5 @@ #/bin/sh -helm-docs - HELM_REPO=${HELM_REPO:-oci://codeberg.org/wrenix/helm-charts} for p in * ; do @@ -10,6 +8,7 @@ for p in * ; do fi echo "${p}:"; + helm-docs -t ../README.md.gotmpl # last pkg lastTag=$(git tag -l "${p}-v*" | tail -1)