[network-ups-tools] add exporter sidecar (#1159)

* [network-ups-tools] add exporter sidecar
This commit is contained in:
j_r0dd 2021-09-09 07:11:57 -04:00 committed by GitHub
parent 31c36ef258
commit caac991f65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 128 additions and 8 deletions

View File

@ -1,8 +1,8 @@
apiVersion: v2 apiVersion: v2
appVersion: v2.7.4-2474-gb4a58380 appVersion: v2.7.4-2479-g86a32237
description: Network UPS Tools is a collection of programs which provide a common interface for monitoring and administering UPS, PDU and SCD hardware. description: Network UPS Tools is a collection of programs which provide a common interface for monitoring and administering UPS, PDU and SCD hardware.
name: network-ups-tools name: network-ups-tools
version: 5.0.0 version: 5.1.0
kubeVersion: ">=1.16.0-0" kubeVersion: ">=1.16.0-0"
keywords: keywords:
- nut - nut

View File

@ -1,6 +1,6 @@
# network-ups-tools # network-ups-tools
![Version: 5.0.0](https://img.shields.io/badge/Version-5.0.0-informational?style=flat-square) ![AppVersion: v2.7.4-2474-gb4a58380](https://img.shields.io/badge/AppVersion-v2.7.4--2474--gb4a58380-informational?style=flat-square) ![Version: 5.1.0](https://img.shields.io/badge/Version-5.1.0-informational?style=flat-square) ![AppVersion: v2.7.4-2479-g86a32237](https://img.shields.io/badge/AppVersion-v2.7.4--2479--g86a32237-informational?style=flat-square)
Network UPS Tools is a collection of programs which provide a common interface for monitoring and administering UPS, PDU and SCD hardware. Network UPS Tools is a collection of programs which provide a common interface for monitoring and administering UPS, PDU and SCD hardware.
@ -79,10 +79,23 @@ N/A
| config.mode | string | `"values"` | If set to 'values', the configuration will be read from these values. Otherwise you have to mount a volume to /etc/nut containing the configuration files. | | config.mode | string | `"values"` | If set to 'values', the configuration will be read from these values. Otherwise you have to mount a volume to /etc/nut containing the configuration files. |
| env | object | See below | environment variables. | | env | object | See below | environment variables. |
| env.TZ | string | `"UTC"` | Set the container timezone | | env.TZ | string | `"UTC"` | Set the container timezone |
| exporter.enabled | bool | See values.yaml | Enable and configure prometheus-nut-exporter sidecar and Prometheus serviceMonitor. |
| exporter.env.logLevel | string | `"info"` | log level [info|debug|trace] |
| exporter.env.port | int | `9995` | metrics port |
| exporter.image.pullPolicy | string | `"IfNotPresent"` | image pull policy |
| exporter.image.repository | string | `"hon95/prometheus-nut-exporter"` | image repository |
| exporter.image.tag | string | `"1.1.1"` | image tag |
| exporter.serviceMonitor.interval | string | `"30s"` | |
| exporter.serviceMonitor.labels | object | `{}` | |
| exporter.serviceMonitor.scrapeTimeout | string | `"10s"` | |
| image.pullPolicy | string | `"IfNotPresent"` | image pull policy | | image.pullPolicy | string | `"IfNotPresent"` | image pull policy |
| image.repository | string | `"ghcr.io/k8s-at-home/network-ups-tools"` | image repository | | image.repository | string | `"ghcr.io/k8s-at-home/network-ups-tools"` | image repository |
| image.tag | string | `"v2.7.4-2474-gb4a58380"` | image tag | | image.tag | string | `"v2.7.4-2479-g86a32237"` | image tag |
| ingress.main | object | See values.yaml | Enable and configure ingress settings for the chart under this key. | | ingress.main | object | See values.yaml | Enable and configure ingress settings for the chart under this key. |
| persistence | object | See values.yaml | Configure persistence settings for the chart under this key. |
| persistence.ups.hostPath | string | `"/dev/bus/usb/001/001"` | The path of the usb ups on the host. |
| persistence.ups.mountPath | string | `"/dev/bus/usb/001/001"` | Optional path for ups to mount in the container. |
| securityContext | object | See values.yaml | Set to true if using ups connected by usb to the host |
| service | object | See values.yaml | Configures service settings for the chart. | | service | object | See values.yaml | Configures service settings for the chart. |
## Changelog ## Changelog
@ -91,6 +104,12 @@ All notable changes to this application Helm chart will be documented in this fi
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### [5.1.0]
### Added
- Added podMonitor and the ability to use [prometheus-nut-exporter](https://github.com/HON95/prometheus-nut-exporter) as a sidecar container.
### [5.0.0] ### [5.0.0]
#### Changed #### Changed
@ -112,6 +131,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Initial version - Initial version
[5.1.0]: #510
[5.0.0]: #500 [5.0.0]: #500
[4.0.0]: #400 [4.0.0]: #400
[1.0.0]: #100 [1.0.0]: #100

View File

@ -9,6 +9,12 @@ All notable changes to this application Helm chart will be documented in this fi
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### [5.1.0]
### Added
- Added podMonitor and the ability to use [prometheus-nut-exporter](https://github.com/HON95/prometheus-nut-exporter) as a sidecar container.
### [5.0.0] ### [5.0.0]
#### Changed #### Changed
@ -30,6 +36,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Initial version - Initial version
[5.1.0]: #510
[5.0.0]: #500 [5.0.0]: #500
[4.0.0]: #400 [4.0.0]: #400
[1.0.0]: #100 [1.0.0]: #100

View File

@ -14,10 +14,35 @@ persistence:
name: {{ printf "%v-config" (include "common.names.fullname" .) }} name: {{ printf "%v-config" (include "common.names.fullname" .) }}
defaultMode: 256 defaultMode: 256
optional: true optional: true
{{ if .Values.exporter.enabled }}
additionalContainers:
exporter:
name: exporter
image: "{{ .Values.exporter.image.repository }}:{{ .Values.exporter.image.tag }}"
imagePullPolicy: {{ .Values.exporter.image.pullPolicy }}
env:
- name: HTTP_PORT
value: "{{ .Values.exporter.env.port }}"
- name: HTTP_PATH
value: "/metrics"
- name: RUST_LOG
value: "{{ .Values.exporter.env.logLevel }}"
ports:
- name: metrics
containerPort: {{ .Values.exporter.env.port }}
service:
metrics:
enabled: true
ports:
metrics:
enabled: true
protocol: TCP
port: {{ .Values.exporter.env.port }}
{{ end }}
{{- end -}} {{- end -}}
{{- if eq .Values.config.mode "values" -}} {{- $_ := mergeOverwrite .Values (include "network-ups-tools.harcodedValues" . | fromYaml) -}}
{{- $_ := mergeOverwrite .Values (include "network-ups-tools.harcodedValues" . | fromYaml) -}}
{{- end -}}
{{/* Render the templates */}} {{/* Render the templates */}}
{{ include "common.all" . }} {{ include "common.all" . }}

View File

@ -0,0 +1,30 @@
{{- if .Values.exporter.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "common.names.fullname" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- with .Values.exporter.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "common.labels.selectorLabels" . | nindent 6 }}
endpoints:
- port: metrics
{{- with .Values.exporter.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with .Values.exporter.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
path: /metrics
params:
target:
- "localhost:{{ .Values.service.main.ports.server.port }}"
relabelings:
- sourceLabels: [__param_target]
targetLabel: target
{{- end }}

View File

@ -9,7 +9,7 @@ image:
# -- image repository # -- image repository
repository: ghcr.io/k8s-at-home/network-ups-tools repository: ghcr.io/k8s-at-home/network-ups-tools
# -- image tag # -- image tag
tag: v2.7.4-2474-gb4a58380 tag: v2.7.4-2479-g86a32237
# -- image pull policy # -- image pull policy
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
@ -37,6 +37,23 @@ ingress:
main: main:
enabled: false enabled: false
# -- Configure persistence settings for the chart under this key.
# @default -- See values.yaml
persistence:
ups:
enabled: false
type: hostPath
# -- The path of the usb ups on the host.
hostPath: /dev/bus/usb/001/001
# -- Optional path for ups to mount in the container.
mountPath: /dev/bus/usb/001/001
readOnly: false
# -- Set to true if using ups connected by usb to the host
# @default -- See values.yaml
securityContext:
privileged: false
config: config:
# -- If set to 'values', the configuration will be read from these values. # -- If set to 'values', the configuration will be read from these values.
# Otherwise you have to mount a volume to /etc/nut containing the configuration files. # Otherwise you have to mount a volume to /etc/nut containing the configuration files.
@ -56,3 +73,24 @@ config:
driver = dummy-ups driver = dummy-ups
port = dummy-ups.dev port = dummy-ups.dev
desc = "dummy-ups in dummy mode" desc = "dummy-ups in dummy mode"
exporter:
# -- Enable and configure prometheus-nut-exporter sidecar and Prometheus serviceMonitor.
# @default -- See values.yaml
enabled: false
serviceMonitor:
interval: 30s
scrapeTimeout: 10s
labels: {}
image:
# -- image repository
repository: hon95/prometheus-nut-exporter
# -- image tag
tag: 1.1.1
# -- image pull policy
pullPolicy: IfNotPresent
env:
# -- metrics port
port: 9995
# -- log level [info|debug|trace]
logLevel: info