Skip to content

Commit

Permalink
add helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
terjesannum committed Mar 23, 2023
1 parent 9df2165 commit 374f3bc
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/easee-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/
26 changes: 26 additions & 0 deletions charts/easee-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v2
name: easee-exporter
version: 0.1.0
description: Easee prometheus exporter
type: application
keywords:
- easee
- prometheus
- grafana
- monitoring
home: https://github.com/terjesannum/easee-exporter
maintainers:
- name: Terje Sannum
email: terje@offpiste.org
url: https://github.com/terjesannum
annotations:
artifacthub.io/images: |
- name: easee-exporter
image: ghcr.io/terjesannum/easee-exporter:latest
platforms:
- linux/amd64
- linux/arm64
- linux/arm/v7
artifacthub.io/screenshots: |
- title: Grafana dashboard
url: https://raw.githubusercontent.com/terjesannum/easee-exporter/master/grafana/dashboard.png
21 changes: 21 additions & 0 deletions charts/easee-exporter/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Terje Sannum

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions charts/easee-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Easee prometheus exporter

Monitor your Easee EV charger with Prometheus and Grafana.

![Grafana dashboard](https://raw.githubusercontent.com/terjesannum/easee-exporter/master/grafana/dashboard.png)

See [https://github.com/terjesannum/easee-exporter](https://github.com/terjesannum/easee-exporter) for more information.
51 changes: 51 additions & 0 deletions charts/easee-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "easee-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 "easee-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 "easee-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "easee-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "easee-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
10 changes: 10 additions & 0 deletions charts/easee-exporter/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
type: kubernetes.io/Opaque
metadata:
name: {{ include "easee-exporter.fullname" . }}
labels:
{{- include "easee-exporter.labels" . | nindent 4 }}
stringData:
username: '{{ required "Easee username is required" .Values.username }}'
password: '{{ required "Easee password is required" .Values.password }}'
17 changes: 17 additions & 0 deletions charts/easee-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "easee-exporter.fullname" . }}
labels:
{{- include "easee-exporter.labels" . | nindent 4 }}
spec:
type: ClusterIP
clusterIP: None
selector:
{{- include "easee-exporter.selectorLabels" . | nindent 4 }}
ports:
- name: http
protocol: TCP
port: 80
targetPort: http
27 changes: 27 additions & 0 deletions charts/easee-exporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "easee-exporter.fullname" . }}
labels:
{{- include "easee-exporter.labels" . | nindent 4 }}
{{- if .Values.serviceMonitor.labels }}
{{- toYaml .Values.serviceMonitor.labels | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "easee-exporter.selectorLabels" . | nindent 6 }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
endpoints:
- path: /metrics
port: http
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
56 changes: 56 additions & 0 deletions charts/easee-exporter/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "easee-exporter.fullname" . }}
labels:
{{- include "easee-exporter.labels" . | nindent 4 }}
spec:
serviceName: {{ include "easee-exporter.fullname" . }}
replicas: 1
selector:
matchLabels:
{{- include "easee-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- if not .Values.serviceMonitor.enabled }}
prometheus.io/scrape: 'true'
{{- end }}
{{- if .Values.podAnnotations }}
{{- toYaml .Values.podAnnotations | nindent 8 }}
{{- end }}
labels:
{{- include "easee-exporter.selectorLabels" . | nindent 8 }}
spec:
restartPolicy: Always
containers:
- name: easee-exporter
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.Version }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
env:
- name: EASEE_USERNAME
valueFrom:
secretKeyRef:
name: "{{ include "easee-exporter.fullname" . }}"
key: username
- name: EASEE_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ include "easee-exporter.fullname" . }}"
key: password
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
36 changes: 36 additions & 0 deletions charts/easee-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
username: ""
password: ""

serviceMonitor:
enabled: false
labels: {}
interval: 1m
scrapeTimeout: 10s

image:
repository: ghcr.io/terjesannum/easee-exporter
# Override image tag (default is chart version)
tag: ""
pullPolicy: IfNotPresent

nameOverride: ""
fullnameOverride: ""

podAnnotations: {}

securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 65532
allowPrivilegeEscalation: false

resources: {}
# limits:
# cpu: 20m
# memory: 32Mi
# requests:
# cpu: 10m
# memory: 32Mi

0 comments on commit 374f3bc

Please sign in to comment.