From 93b52f191054a6451369ebc49b4e072903c15384 Mon Sep 17 00:00:00 2001 From: Philipp Hellmich Date: Fri, 3 Jun 2022 14:28:00 +0200 Subject: [PATCH] [mqtt-exporter] Add new chart (#1584) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added mqtt-exporter * added servicemonitor * fix interval * fix timeout * exclude from ct * docs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/templates/servicemonitor.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * Update charts/stable/mqtt-exporter/values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs * fix ci * fix docs * fixes * Update values.yaml * Update values.yaml Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs --- charts/stable/mqtt-exporter/.helmignore | 26 ++++++ charts/stable/mqtt-exporter/Chart.yaml | 26 ++++++ charts/stable/mqtt-exporter/README.md | 62 ++++++++++++++ .../mqtt-exporter/README_CONFIG.md.gotmpl | 9 ++ charts/stable/mqtt-exporter/ci/ct-values.yaml | 10 +++ .../stable/mqtt-exporter/templates/NOTES.txt | 1 + .../mqtt-exporter/templates/common.yaml | 1 + .../templates/servicemonitor.yaml | 28 ++++++ charts/stable/mqtt-exporter/values.yaml | 85 +++++++++++++++++++ 9 files changed, 248 insertions(+) create mode 100644 charts/stable/mqtt-exporter/.helmignore create mode 100644 charts/stable/mqtt-exporter/Chart.yaml create mode 100644 charts/stable/mqtt-exporter/README.md create mode 100644 charts/stable/mqtt-exporter/README_CONFIG.md.gotmpl create mode 100644 charts/stable/mqtt-exporter/ci/ct-values.yaml create mode 100644 charts/stable/mqtt-exporter/templates/NOTES.txt create mode 100644 charts/stable/mqtt-exporter/templates/common.yaml create mode 100644 charts/stable/mqtt-exporter/templates/servicemonitor.yaml create mode 100644 charts/stable/mqtt-exporter/values.yaml diff --git a/charts/stable/mqtt-exporter/.helmignore b/charts/stable/mqtt-exporter/.helmignore new file mode 100644 index 00000000..4379e2b3 --- /dev/null +++ b/charts/stable/mqtt-exporter/.helmignore @@ -0,0 +1,26 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ +# OWNERS file for Kubernetes +OWNERS +# helm-docs templates +*.gotmpl diff --git a/charts/stable/mqtt-exporter/Chart.yaml b/charts/stable/mqtt-exporter/Chart.yaml new file mode 100644 index 00000000..7ff50a3a --- /dev/null +++ b/charts/stable/mqtt-exporter/Chart.yaml @@ -0,0 +1,26 @@ +--- +apiVersion: v2 +appVersion: 1.0.0 +description: Simple and generic Prometheus exporter for MQTT. Tested with Mosquitto MQTT and Xiaomi sensors. +name: mqtt-exporter +version: 1.0.0 +kubeVersion: ">=1.16.0-0" +keywords: + - zigbee2mqtt + - prometheus +home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/mqtt-exporter +icon: https://static.veritone.com/assets/favicon/favicon.ico +sources: + - https://github.com/kpetremann/mqtt-exporter + - https://hub.docker.com/r/kpetrem/mqtt-exporter +maintainers: + - name: philipp + email: phil@hellmi.de +dependencies: + - name: common + repository: https://library-charts.k8s-at-home.com + version: 4.4.2 +annotations: + artifacthub.io/changes: |- + - kind: added + description: Initial version diff --git a/charts/stable/mqtt-exporter/README.md b/charts/stable/mqtt-exporter/README.md new file mode 100644 index 00000000..2fa4beb2 --- /dev/null +++ b/charts/stable/mqtt-exporter/README.md @@ -0,0 +1,62 @@ +# mqtt-exporter + +![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) + +Simple and generic Prometheus exporter for MQTT. Tested with Mosquitto MQTT and Xiaomi sensors. + +**Homepage:** + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| philipp | phil@hellmi.de | | + +## Source Code + +* +* + +## Requirements + +Kubernetes: `>=1.16.0-0` + +| Repository | Name | Version | +|------------|------|---------| +| https://library-charts.k8s-at-home.com | common | 4.4.2 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| env | object | See below | environment variables. See [image docs](https://developer.us-1.veritone.com/machinebox/overview) for more details. | +| env.LOG_LEVEL | string | `"INFO"` | Logging level | +| env.MQTT_ADDRESS | string | `"127.0.0.1"` | IP or hostname of MQTT broker | +| env.MQTT_IGNORED_TOPICS | string | `nil` | Comma-separated lists of topics to ignore. Accepts wildcards. | +| env.MQTT_KEEPALIVE | int | `60` | Keep alive interval to maintain connection with MQTT broker | +| env.MQTT_PASSWORD | string | `nil` | Password which should be used to authenticate against the MQTT broker | +| env.MQTT_PORT | int | `1883` | TCP port of MQTT broker | +| env.MQTT_TOPIC | string | `"#"` | Topic path to subscribe to | +| env.MQTT_USERNAME | string | `nil` | Username which should be used to authenticate against the MQTT broker | +| env.PROMETHEUS_PORT | int | `9000` | HTTP server PORT to expose Prometheus metrics | +| env.PROMETHEUS_PREFIX | string | `"mqtt_"` | Prefix added to the metric name, example: mqtt_temperature | +| env.TOPIC_LABEL | string | `"topic"` | Define the Prometheus label for the topic, example temperature{topic="device1"} | +| env.TZ | string | `"UTC"` | Set the container timezone | +| env.ZIGBEE2MQTT_AVAILABILITY | string | `"False"` | Normalize sensor name for device availability metric added by Zigbee2MQTT | +| image.pullPolicy | string | `"IfNotPresent"` | image pull policy | +| image.repository | string | `"kpetrem/mqtt-exporter"` | image repository | +| image.tag | string | `"latest"` | image tag | +| ingress.main | object | See values.yaml | Enable and configure ingress settings for the chart under this key. | +| metrics.enabled | bool | See values.yaml | Enable and configure a Prometheus serviceMonitor for the chart under this key. | +| metrics.serviceMonitor.interval | string | `"30s"` | Interval at which Prometheus should scrape metrics | +| metrics.serviceMonitor.labels | object | `{}` | Additional labels for the Kubernetes `ServiceMonitor` object | +| metrics.serviceMonitor.scrapeTimeout | string | `"10s"` | Timeout after which the scrape is ended | +| persistence | object | See values.yaml | Configure persistence settings for the chart under this key. | +| securityContext.capabilities.drop[0] | string | `"ALL"` | | +| securityContext.readOnlyRootFilesystem | bool | `true` | | +| securityContext.runAsNonRoot | bool | `true` | | +| securityContext.runAsUser | int | `65534` | | +| service | object | See values.yaml | Configures service settings for the chart. | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) diff --git a/charts/stable/mqtt-exporter/README_CONFIG.md.gotmpl b/charts/stable/mqtt-exporter/README_CONFIG.md.gotmpl new file mode 100644 index 00000000..e93d80bf --- /dev/null +++ b/charts/stable/mqtt-exporter/README_CONFIG.md.gotmpl @@ -0,0 +1,9 @@ +{{- define "custom.custom.configuration.header" -}} +## Custom configuration +{{- end -}} + +{{- define "custom.custom.configuration" -}} +{{ template "custom.custom.configuration.header" . }} + +N/A +{{- end -}} diff --git a/charts/stable/mqtt-exporter/ci/ct-values.yaml b/charts/stable/mqtt-exporter/ci/ct-values.yaml new file mode 100644 index 00000000..40692998 --- /dev/null +++ b/charts/stable/mqtt-exporter/ci/ct-values.yaml @@ -0,0 +1,10 @@ +# Test + +additionalContainers: + mosquitto: + name: mosquitto + image: eclipse-mosquitto:1.6.8 + imagePullPolicy: IfNotPresent + ports: + - name: mqtt + containerPort: 1883 diff --git a/charts/stable/mqtt-exporter/templates/NOTES.txt b/charts/stable/mqtt-exporter/templates/NOTES.txt new file mode 100644 index 00000000..90f7b653 --- /dev/null +++ b/charts/stable/mqtt-exporter/templates/NOTES.txt @@ -0,0 +1 @@ +{{- include "common.notes.defaultNotes" . -}} diff --git a/charts/stable/mqtt-exporter/templates/common.yaml b/charts/stable/mqtt-exporter/templates/common.yaml new file mode 100644 index 00000000..a6613c2c --- /dev/null +++ b/charts/stable/mqtt-exporter/templates/common.yaml @@ -0,0 +1 @@ +{{ include "common.all" . }} diff --git a/charts/stable/mqtt-exporter/templates/servicemonitor.yaml b/charts/stable/mqtt-exporter/templates/servicemonitor.yaml new file mode 100644 index 00000000..9948b197 --- /dev/null +++ b/charts/stable/mqtt-exporter/templates/servicemonitor.yaml @@ -0,0 +1,28 @@ +{{- if .Values.metrics.enabled }} +{{- include "common.values.setup" . -}} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "common.names.fullname" . }} + labels: + {{- include "common.labels" . | nindent 4 }} + {{- with .Values.metrics.serviceMonitor.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + annotations: + {{- include "common.annotations" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "common.labels.selectorLabels" . | nindent 6 }} + endpoints: + - port: http + {{- with .Values.metrics.serviceMonitor.interval }} + interval: {{ . }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ . }} + {{- end }} + path: /metrics +{{- end }} diff --git a/charts/stable/mqtt-exporter/values.yaml b/charts/stable/mqtt-exporter/values.yaml new file mode 100644 index 00000000..77f816d2 --- /dev/null +++ b/charts/stable/mqtt-exporter/values.yaml @@ -0,0 +1,85 @@ +# +# IMPORTANT NOTE +# +# This chart inherits from our common library chart. You can check the default values/options here: +# https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml +# + +image: + # -- image repository + repository: kpetrem/mqtt-exporter + # -- image tag + tag: latest + # -- image pull policy + pullPolicy: IfNotPresent + +# -- environment variables. See [image docs](https://developer.us-1.veritone.com/machinebox/overview) for more details. +# @default -- See below +env: + # -- Set the container timezone + TZ: UTC + # -- Logging level + LOG_LEVEL: INFO + # -- Comma-separated lists of topics to ignore. Accepts wildcards. + MQTT_IGNORED_TOPICS: + # -- IP or hostname of MQTT broker + MQTT_ADDRESS: 127.0.0.1 + # -- TCP port of MQTT broker + MQTT_PORT: 1883 + # -- Topic path to subscribe to + MQTT_TOPIC: "#" + # -- Keep alive interval to maintain connection with MQTT broker + MQTT_KEEPALIVE: 60 + # -- Username which should be used to authenticate against the MQTT broker + MQTT_USERNAME: + # -- Password which should be used to authenticate against the MQTT broker + MQTT_PASSWORD: + # -- HTTP server PORT to expose Prometheus metrics + PROMETHEUS_PORT: 9000 + # -- Prefix added to the metric name, example: mqtt_temperature + PROMETHEUS_PREFIX: mqtt_ + # -- Define the Prometheus label for the topic, example temperature{topic="device1"} + TOPIC_LABEL: topic + # -- Normalize sensor name for device availability metric added by Zigbee2MQTT + ZIGBEE2MQTT_AVAILABILITY: "False" + +# -- Configures service settings for the chart. +# @default -- See values.yaml +service: + main: + ports: + http: + port: 9000 + +metrics: + # -- Enable and configure a Prometheus serviceMonitor for the chart under this key. + # @default -- See values.yaml + enabled: false + serviceMonitor: + # -- Interval at which Prometheus should scrape metrics + interval: 30s + # -- Timeout after which the scrape is ended + scrapeTimeout: 10s + # -- Additional labels for the Kubernetes `ServiceMonitor` object + labels: {} + +ingress: + # -- Enable and configure ingress settings for the chart under this key. + # @default -- See values.yaml + main: + enabled: false + +# -- Configure persistence settings for the chart under this key. +# @default -- See values.yaml +persistence: + config: + enabled: false + mountPath: /conf + +securityContext: + capabilities: + drop: + - ALL + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 65534