From d0fa89fa6b5823335d36416354b61ddc0cd8c935 Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin <3811295@gmail.com> Date: Wed, 27 Sep 2023 14:51:51 +0400 Subject: [PATCH] [prometheus-ipmi-exporter] Add ipmi-exporter chart (#3740) * add ipmi-exporter Signed-off-by: Aleksey Sviridkin * switch to "official" image Signed-off-by: Aleksey Sviridkin * add maintainer, keywords and home link Signed-off-by: Aleksey Sviridkin * Update CODEOWNERS Signed-off-by: MH * fix linting Signed-off-by: Aleksey Sviridkin * Update charts/prometheus-ipmi-exporter/templates/deployment.yaml Signed-off-by: MH --------- Signed-off-by: Aleksey Sviridkin Signed-off-by: MH Co-authored-by: MH --- .github/CODEOWNERS | 1 + charts/prometheus-ipmi-exporter/.helmignore | 23 +++ charts/prometheus-ipmi-exporter/Chart.yaml | 20 +++ .../templates/NOTES.txt | 22 +++ .../templates/_helpers.tpl | 85 +++++++++++ .../templates/configmap.yaml | 13 ++ .../templates/deployment.yaml | 62 ++++++++ .../templates/service.yaml | 17 +++ .../templates/servicemonitor.yaml | 44 ++++++ charts/prometheus-ipmi-exporter/values.yaml | 139 ++++++++++++++++++ 10 files changed, 426 insertions(+) create mode 100644 charts/prometheus-ipmi-exporter/.helmignore create mode 100644 charts/prometheus-ipmi-exporter/Chart.yaml create mode 100644 charts/prometheus-ipmi-exporter/templates/NOTES.txt create mode 100644 charts/prometheus-ipmi-exporter/templates/_helpers.tpl create mode 100644 charts/prometheus-ipmi-exporter/templates/configmap.yaml create mode 100644 charts/prometheus-ipmi-exporter/templates/deployment.yaml create mode 100644 charts/prometheus-ipmi-exporter/templates/service.yaml create mode 100644 charts/prometheus-ipmi-exporter/templates/servicemonitor.yaml create mode 100644 charts/prometheus-ipmi-exporter/values.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 156aee91395d..059d64c82cc6 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -22,6 +22,7 @@ /charts/prometheus-druid-exporter/ @iamabhishek-dubey @sandy724 /charts/prometheus-elasticsearch-exporter/ @desaintmartin @svenmueller @zeritti /charts/prometheus-fastly-exporter/ @arslanbekov +/charts/prometheus-ipmi-exporter/ @lexfrei /charts/prometheus-json-exporter/ @schmiddim @xiu @zanhsieh /charts/prometheus-kafka-exporter/ @gkarthiks @golgoth31 @zeritti /charts/prometheus-modbus-exporter/ @openenergyprojects diff --git a/charts/prometheus-ipmi-exporter/.helmignore b/charts/prometheus-ipmi-exporter/.helmignore new file mode 100644 index 000000000000..0e8a0eb36f4c --- /dev/null +++ b/charts/prometheus-ipmi-exporter/.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/charts/prometheus-ipmi-exporter/Chart.yaml b/charts/prometheus-ipmi-exporter/Chart.yaml new file mode 100644 index 000000000000..410ad6fd7f8a --- /dev/null +++ b/charts/prometheus-ipmi-exporter/Chart.yaml @@ -0,0 +1,20 @@ +apiVersion: v2 +name: prometheus-ipmi-exporter +description: This is an IPMI exporter for Prometheus. + +type: application + +version: 0.1.0 + +appVersion: "1.6.1" + +keywords: + - metrics + - ipmi + - monitoring + +home: https://github.com/prometheus-community/ipmi_exporter + +maintainers: + - name: lexfrei + email: f@lex.la diff --git a/charts/prometheus-ipmi-exporter/templates/NOTES.txt b/charts/prometheus-ipmi-exporter/templates/NOTES.txt new file mode 100644 index 000000000000..9695ea1d1bd0 --- /dev/null +++ b/charts/prometheus-ipmi-exporter/templates/NOTES.txt @@ -0,0 +1,22 @@ +Thank you for installing prometheus-ipmi-exporter! + +Your release is named: {{ .Release.Name }} + +To view the IPMI Exporter service within your cluster, you can run: + + kubectl get svc {{ .Release.Name }}-ipmi-exporter-service + +{{- if .Values.serviceMonitor.enabled }} +ServiceMonitor has been installed. Make sure you've installed Prometheus Operator in your cluster and then verify that the target is up in your Prometheus instance. +{{- else }} +Note: ServiceMonitor is disabled. If you want to enable monitoring through Prometheus Operator, please set `serviceMonitor.enabled` to `true` in the values.yaml file or via --set flag. +{{- end }} + +{{- if .Values.resources }} +Resource requests and limits are set as follows: + + CPU Requests: {{ .Values.resources.requests.cpu }} + Memory Requests: {{ .Values.resources.requests.memory }} + CPU Limits: {{ .Values.resources.limits.cpu }} + Memory Limits: {{ .Values.resources.limits.memory }} +{{- end }} diff --git a/charts/prometheus-ipmi-exporter/templates/_helpers.tpl b/charts/prometheus-ipmi-exporter/templates/_helpers.tpl new file mode 100644 index 000000000000..f608f7621dbc --- /dev/null +++ b/charts/prometheus-ipmi-exporter/templates/_helpers.tpl @@ -0,0 +1,85 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "prometheus-ipmi-exporter.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "prometheus-ipmi-exporter.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "prometheus-ipmi-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "prometheus-ipmi-exporter.labels" -}} +helm.sh/chart: {{ include "prometheus-ipmi-exporter.chart" . }} +{{ include "prometheus-ipmi-exporter.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "prometheus-ipmi-exporter.selectorLabels" -}} +app.kubernetes.io/name: {{ include "prometheus-ipmi-exporter.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "prometheus-ipmi-exporter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} +{{- default (include "prometheus-ipmi-exporter.fullname" .) .Values.serviceAccount.name }} +{{- else -}} +{{- default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} + +{{/* +Return the appropriate apiVersion for rbac. +*/}} +{{- define "rbac.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" }} +{{- print "rbac.authorization.k8s.io/v1" -}} +{{- else -}} +{{- print "rbac.authorization.k8s.io/v1beta1" -}} +{{- end -}} +{{- end -}} + +{{/* +Determine secret name, can either be the self-created of an existing one +*/}} +{{- define "prometheus-ipmi-exporter.secretName" -}} +{{- if .Values.existingSecret.name -}} + {{- .Values.existingSecret.name -}} +{{- else -}} + {{ include "prometheus-ipmi-exporter.fullname" . }} +{{- end -}} +{{- end -}} diff --git a/charts/prometheus-ipmi-exporter/templates/configmap.yaml b/charts/prometheus-ipmi-exporter/templates/configmap.yaml new file mode 100644 index 000000000000..fabf77404ca6 --- /dev/null +++ b/charts/prometheus-ipmi-exporter/templates/configmap.yaml @@ -0,0 +1,13 @@ +{{- if not .Values.configMapFile -}} +{{- $fullName := include "prometheus-ipmi-exporter.fullname" . -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ $fullName }} + labels: + {{- include "prometheus-ipmi-exporter.labels" . | nindent 4 }} +data: + config.yml: | + modules: +{{- toYaml .Values.modules | nindent 6 }} +{{- end }} diff --git a/charts/prometheus-ipmi-exporter/templates/deployment.yaml b/charts/prometheus-ipmi-exporter/templates/deployment.yaml new file mode 100644 index 000000000000..1868cc877764 --- /dev/null +++ b/charts/prometheus-ipmi-exporter/templates/deployment.yaml @@ -0,0 +1,62 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "prometheus-ipmi-exporter.fullname" . }} + labels: + {{- include "prometheus-ipmi-exporter.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "prometheus-ipmi-exporter.selectorLabels" . | nindent 6 }} + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + labels: + {{- include "prometheus-ipmi-exporter.selectorLabels" . | nindent 8 }} + {{- with .Values.additionalAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + containers: + - name: ipmi-exporter + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "--config.file" + - "/config.yml" + volumeMounts: + - name: config-volume + mountPath: /config.yml + subPath: config.yml + readOnly: true + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + resources: + limits: + cpu: {{ .Values.resources.limits.cpu }} + memory: {{ .Values.resources.limits.memory }} + requests: + cpu: {{ .Values.resources.requests.cpu }} + memory: {{ .Values.resources.requests.memory }} + volumes: + - name: config-volume + configMap: + name: {{ template "prometheus-ipmi-exporter.fullname" . }} + {{- with .Values.nodeSelector }} + nodeSelector: {{ toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: {{ toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: {{ toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/prometheus-ipmi-exporter/templates/service.yaml b/charts/prometheus-ipmi-exporter/templates/service.yaml new file mode 100644 index 000000000000..1682f0d9f0a2 --- /dev/null +++ b/charts/prometheus-ipmi-exporter/templates/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "prometheus-ipmi-exporter.fullname" . }} + labels: + {{- include "prometheus-ipmi-exporter.labels" . | nindent 4 }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "prometheus-ipmi-exporter.selectorLabels" . | nindent 4 }} diff --git a/charts/prometheus-ipmi-exporter/templates/servicemonitor.yaml b/charts/prometheus-ipmi-exporter/templates/servicemonitor.yaml new file mode 100644 index 000000000000..2ffcd72970e4 --- /dev/null +++ b/charts/prometheus-ipmi-exporter/templates/servicemonitor.yaml @@ -0,0 +1,44 @@ +{{- if $.Values.serviceMonitor }} +{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.serviceMonitor.enabled ) }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: +{{- if .Values.serviceMonitor.labels }} + labels: +{{ toYaml .Values.serviceMonitor.labels | indent 4}} +{{- end }} + name: {{ template "prometheus-ipmi-exporter.fullname" . }} +{{- if .Values.serviceMonitor.namespace }} + namespace: {{ .Values.serviceMonitor.namespace }} +{{- end }} +spec: + endpoints: + - targetPort: {{ .Values.service.port }} +{{- if .Values.serviceMonitor.interval }} + interval: {{ .Values.serviceMonitor.interval }} +{{- end }} +{{- if .Values.serviceMonitor.telemetryPath }} + path: {{ .Values.serviceMonitor.telemetryPath }} +{{- end }} +{{- if .Values.serviceMonitor.timeout }} + scrapeTimeout: {{ .Values.serviceMonitor.timeout }} +{{- end }} +{{- if .Values.serviceMonitor.metricRelabelings }} + metricRelabelings: +{{ toYaml .Values.serviceMonitor.metricRelabelings | indent 4 }} +{{- end }} + jobLabel: {{ template "prometheus-ipmi-exporter.fullname" . }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + {{- include "prometheus-ipmi-exporter.selectorLabels" . | nindent 6 }} +{{- if .Values.serviceMonitor.targetLabels }} + targetLabels: +{{- range .Values.serviceMonitor.targetLabels }} + - {{ . }} +{{- end }} +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/prometheus-ipmi-exporter/values.yaml b/charts/prometheus-ipmi-exporter/values.yaml new file mode 100644 index 000000000000..a51795cb842c --- /dev/null +++ b/charts/prometheus-ipmi-exporter/values.yaml @@ -0,0 +1,139 @@ +# Default values for prometheus-ipmi-exporter. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: registry.hub.docker.com/prometheuscommunity/ipmi-exporter + tag: v1.6.1 + pullPolicy: IfNotPresent + +# Name of an externally managed secret (in the same namespace) containing the ipmi credentials as keys `ipmi-user` and `ipmi-password`. +nodeSelector: {} + +# Name of an externally managed secret (in the same namespace) containing the ipmi credentials as keys `ipmi-user` and `ipmi-password`. +tolerations: [] + +# Name of an externally managed secret (in the same namespace) containing the ipmi credentials as keys `ipmi-user` and `ipmi-password`. +affinity: {} + +# Name of an externally managed secret (in the same namespace) containing the ipmi credentials as keys `ipmi-user` and `ipmi-password`. +service: + type: ClusterIP + port: 9290 + annotations: {} + +resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + +additionalAnnotations: {} + +serviceMonitor: + # When set true then use a ServiceMonitor to configure scraping + enabled: false + # Set the namespace the ServiceMonitor should be deployed + # namespace: monitoring + # Set how frequently Prometheus should scrape + # interval: 30s + # Set path to ipmi-exporter telemtery-path + # telemetryPath: /metrics + # Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator + # labels: + # Set timeout for scrape + # timeout: 10s + # Set of labels to transfer on the Kubernetes Service onto the target. + # targetLabels: [] + # metricRelabelings: [] + + # Configuration file for ipmi_exporter + +# This is an example config for scraping remote hosts via IPMI. +# Information required to access remote IPMI interfaces can be supplied in the +# 'modules' section. A scrape can request the usage of a given config by +# setting the `module` URL parameter. +modules: + default: + # These settings are used if no module is specified, the + # specified module doesn't exist, or of course if + # module=default is specified. + user: "default_user" + pass: "example_pw" + # The below settings correspond to driver-type, privilege-level, and + # session-timeout respectively, see `man 5 freeipmi.conf` (and e.g. + # `man 8 ipmi-sensors` for a list of driver types). + driver: "LAN_2_0" + privilege: "user" + # The session timeout is in milliseconds. Note that a scrape can take up + # to (session-timeout * #-of-collectors) milliseconds, so set the scrape + # timeout in Prometheus accordingly. + # Must be larger than the retransmission timeout, which defaults to 1000. + timeout: 10000 + # Available collectors are bmc, ipmi, chassis, dcmi, sel, and sm-lan-mode + # If _not_ specified, bmc, ipmi, chassis, and dcmi are used + collectors: + - bmc + - ipmi + - chassis + # Got any sensors you don't care about? Add them here. + exclude_sensor_ids: + - 2 + - 29 + - 32 + - 50 + - 52 + - 55 + dcmi: + # Use these settings when scraped with module=dcmi. + user: "admin_user" + pass: "another_pw" + privilege: "admin" + driver: "LAN_2_0" + collectors: + - dcmi + thatspecialhost: + # Use these settings when scraped with module=thatspecialhost. + user: "some_user" + pass: "secret_pw" + privilege: "admin" + driver: "LAN" + collectors: + - ipmi + - sel + # Need any special workaround flags set? Add them here. + # Workaround flags might be needed to address issues with specific vendor implementations + # e.g. https://www.gnu.org/software/freeipmi/freeipmi-faq.html#Why-is-the-output-from-FreeIPMI-different-than-another-software_003f + # For a full list of flags, refer to: + # https://www.gnu.org/software/freeipmi/manpages/man8/ipmi-sensors.8.html#lbAL + workaround_flags: + - discretereading + # If you require additional command line arguments (e.g. --bridge-sensors for ipmimonitoring), + # you can specify them per collector - BE CAREFUL, you can easily break the exporter with this! + custom_args: + ipmi: + - "--bridge-sensors" + advanced: + # Use these settings when scraped with module=advanced. + user: "some_user" + pass: "secret_pw" + privilege: "admin" + driver: "LAN" + collectors: + - ipmi + - sel + # USING ANY OF THE BELOW VOIDS YOUR WARRANTY! YOU MAY GET BITTEN BY SHARKS! + # You can override the command to be executed for a collector. Paired with + # custom_args, this can be used to e.g. execute the IPMI tools with sudo: + collector_cmd: + ipmi: sudo + sel: sudo + custom_args: + ipmi: + - "ipmimonitoring" + sel: + - "ipmi-sel"