Skip to content

Commit

Permalink
Merge pull request #108 from ccremer/stiebeleltron-exporter
Browse files Browse the repository at this point in the history
Add stiebeleltron-exporter chart
  • Loading branch information
ccremer authored Dec 11, 2021
2 parents b28f678 + 19f9ee6 commit 8100a27
Show file tree
Hide file tree
Showing 14 changed files with 633 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
| [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/fronius-stack-0.1.4/total)](https://github.com/ccremer/charts/releases/tag/fronius-stack-0.1.4) | [fronius-stack](charts/fronius-stack/README.md) |
| [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/kubernetes-zfs-provisioner-1.1.2/total)](https://github.com/ccremer/charts/releases/tag/kubernetes-zfs-provisioner-1.1.2) | [kubernetes-zfs-provisioner](charts/kubernetes-zfs-provisioner/README.md) |
| [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/samba-0.1.1/total)](https://github.com/ccremer/charts/releases/tag/samba-0.1.1) | [samba](charts/samba/README.md) |
| [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/stiebeleltron-exporter-0.1.0/total)](https://github.com/ccremer/charts/releases/tag/stiebeleltron-exporter-0.1.0) | [stiebeleltron-exporter](charts/stiebeleltron-exporter/README.md) |
| [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/znapzend-0.5.4/total)](https://github.com/ccremer/charts/releases/tag/znapzend-0.5.4) | [znapzend](charts/znapzend/README.md) |

## Development
Expand Down
23 changes: 23 additions & 0 deletions charts/stiebeleltron-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
35 changes: 35 additions & 0 deletions charts/stiebeleltron-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: v2
name: stiebeleltron-exporter
description: Prometheus Exporter for Stiebel Eltron heat pump ISG

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
#appVersion: "1.16.0"

keywords:
- stiebel eltron
- isg
- heat pump
- exporter
- prometheus
icon: https://www.stiebel-eltron.com/apps/ste/docroot/images/single/logo-stiebel-eltron-red-black.svg
home: https://github.com/ccremer/stiebeleltron-exporter
sources:
- https://github.com/ccremer/stiebeleltron-exporter
20 changes: 20 additions & 0 deletions charts/stiebeleltron-exporter/README.gotmpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

## Prometheus Operator

This chart features templates for [Prometheus Operator][prometheus-operator] if desired.
If you'd like to add additional Prometheus labels to all metrics, you could make use of relabelings:

```yaml
serviceMonitor:
enabled: true
metricRelabelings:
- targetLabel: site
replacement: my-home
```
<!---
Common/Useful Link references from values.yaml
-->
[resource-units]: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-units-in-kubernetes
[prometheus-operator]: https://github.com/coreos/prometheus-operator
[prom-relabel-config]: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#relabelconfig
89 changes: 89 additions & 0 deletions charts/stiebeleltron-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# stiebeleltron-exporter

![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)

Prometheus Exporter for Stiebel Eltron heat pump ISG

**Homepage:** <https://github.com/ccremer/stiebeleltron-exporter>

## Installation

```bash
helm repo add ccremer https://ccremer.github.io/charts
helm install stiebeleltron-exporter ccremer/stiebeleltron-exporter
```

## Prometheus Operator

This chart features templates for [Prometheus Operator][prometheus-operator] if desired.
If you'd like to add additional Prometheus labels to all metrics, you could make use of relabelings:

```yaml
serviceMonitor:
enabled: true
metricRelabelings:
- targetLabel: site
replacement: my-home
```
<!---
Common/Useful Link references from values.yaml
-->
[resource-units]: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-units-in-kubernetes
[prometheus-operator]: https://github.com/coreos/prometheus-operator
[prom-relabel-config]: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#relabelconfig
## Source Code
* <https://github.com/ccremer/stiebeleltron-exporter>
## Values
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| exporter.additionalArgs | list | `[]` | Provide additional CLI flags via string array |
| exporter.isgUrl | string | `"http://isg.ip.or.hostname"` | Target URL of Stiebel Eltron ISG device. **Required** |
| exporter.timeoutSeconds | int | `5` | Time after which collecting may time out. Should not be higher than the Prometheus scrape interval. |
| fullnameOverride | string | `""` | |
| hostAliases | object | `{}` | A dict with `{ip, hostnames array}` to configure custom entries in /etc/hosts. See [values.yaml](./values.yaml) for an example. |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.registry | string | `"ghcr.io"` | Container image registry |
| image.repository | string | `"ccremer/stiebeleltron-exporter"` | Location of the container image |
| image.tag | string | `"v0.1.0"` | Container image tag |
| imagePullSecrets | list | `[]` | List of image pull secrets if you use a privately hosted image |
| ingress.annotations | object | `{}` | Additional annotations for the Ingress object |
| ingress.enabled | bool | `false` | Useful if your Prometheus is outside of the cluster |
| ingress.hosts | list | `[]` | See Kubernetes Docs for a guide to setup Ingress hosts |
| ingress.tls | list | `[]` | See Kubernetes Docs for a guide to setup TLS on Ingress |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podSecurityContext | object | `{}` | |
| replicaCount | int | `1` | Usually `1` is fine |
| resources.limits.memory | string | `"64Mi"` | |
| resources.requests.cpu | string | `"20m"` | |
| resources.requests.memory | string | `"32Mi"` | |
| securityContext | object | `{}` | |
| service.nodePort | int | `0` | Node port number if `type` is `NodePort` |
| service.port | int | `8080` | Service port number |
| service.type | string | `"ClusterIP"` | Service type |
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and `create` is `true`, a name is generated using the fullname template |
| serviceMonitor.additionalLabels | object | `{}` | Add custom labels to the ServiceMonitor object |
| serviceMonitor.enabled | bool | `false` | Deploy a ServiceMonitor object for Prometheus. Requires an installed [Prometheus Operator][prometheus-operator]. |
| serviceMonitor.metricRelabelings | list | `[]` | Add relabeling configs before ingestion, see [RelabelConfig][prom-relabel-config]. |
| serviceMonitor.namespace | string | `""` | Namespace in which to deploy the ServiceMonitor, defaults to release namespace. |
| serviceMonitor.scrapeInterval | string | `""` | Override default scrape interval from Prometheus |
| telegraf.enabled | bool | `false` | Whether to enable Telegraf sidecar for Influxdb |
| telegraf.globalTags | object | `{}` | A dict with `key: value` to add to `global_tags` config |
| telegraf.image.registry | string | `"docker.io"` | |
| telegraf.image.repository | string | `"library/telegraf"` | Telegraf image location |
| telegraf.image.tag | string | `"1.20-alpine"` | Telegraf image tag |
| telegraf.influxdb.bucket | string | `"stiebeleltron"` | Bucket to write metrics into |
| telegraf.influxdb.organization | string | `"stiebeleltron"` | Organization where the bucket belongs to |
| telegraf.influxdb.token | string | `""` | Token used to authenticate to InfluxDB |
| telegraf.influxdb.url | string | `"http://influxdb2"` | URL of an InfluxDB 2 instance |
| telegraf.interval | string | `"30s"` | Go-style interval in which metrics are pushed to InfluxDB |
| tolerations | list | `[]` | |
22 changes: 22 additions & 0 deletions charts/stiebeleltron-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "stiebeleltron-exporter.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "stiebeleltron-exporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "stiebeleltron-exporter.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "stiebeleltron-exporter.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
72 changes: 72 additions & 0 deletions charts/stiebeleltron-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "stiebeleltron-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 "stiebeleltron-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 "stiebeleltron-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "stiebeleltron-exporter.labels" -}}
helm.sh/chart: {{ include "stiebeleltron-exporter.chart" . }}
{{ include "stiebeleltron-exporter.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "stiebeleltron-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "stiebeleltron-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "stiebeleltron-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "stiebeleltron-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Container images
*/}}
{{- define "stiebeleltron-exporter.image" -}}
{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}
{{- end }}
{{- define "stiebeleltron-exporter.telegrafImage" -}}
{{ .Values.telegraf.image.registry }}/{{ .Values.telegraf.image.repository }}:{{ .Values.telegraf.image.tag }}
{{- end }}
95 changes: 95 additions & 0 deletions charts/stiebeleltron-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "stiebeleltron-exporter.fullname" . }}
labels:
{{- include "stiebeleltron-exporter.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "stiebeleltron-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- if or .Values.telegraf.enabled .Values.podAnnotations }}
annotations:
{{- if .Values.telegraf.enabled }}
app.kubernetes.io/checksum: telegraf={{ include (print $.Template.BasePath "/telegraf-secret.yaml") . | sha256sum }}
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
labels:
{{- include "stiebeleltron-exporter.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "stiebeleltron-exporter.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: exporter
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ include "stiebeleltron-exporter.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- --isg.url={{ .Values.exporter.isgUrl }}
- --isg.timeout={{ .Values.exporter.timeoutSeconds }}
{{- range .Values.exporter.additionalArgs }}
- {{ . }}
{{- end }}
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /liveness
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.telegraf.enabled }}
- name: telegraf
image: {{ include "stiebeleltron-exporter.telegrafImage" . }}
resources:
limits:
cpu: 200m
memory: 200Mi
requests:
cpu: 10m
memory: 10Mi
volumeMounts:
- name: telegraf-config
mountPath: /etc/telegraf
volumes:
- name: telegraf-config
secret:
secretName: {{ template "stiebeleltron-exporter.fullname" . }}
defaultMode: 420
{{- end }}
{{- with .Values.hostAliases }}
hostAliases:
{{- range $ip, $hostnames := . }}
- ip: {{ $ip }}
hostnames:
{{- range . }}
- {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Loading

0 comments on commit 8100a27

Please sign in to comment.