Skip to content

Commit

Permalink
feat(zfs-exporter): added zfs-exporter helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Tassatux committed Feb 11, 2025
1 parent 3757769 commit ee113fe
Show file tree
Hide file tree
Showing 10 changed files with 296 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/zfs-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/
6 changes: 6 additions & 0 deletions charts/zfs-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: zfs-exporter
description: A Helm chart of https://github.com/pdf/zfs_exporter for Kubernetes
type: application
version: "1.1.0"
appVersion: "v2.3.4"
1 change: 1 addition & 0 deletions charts/zfs-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Zfs-exporter deployed.
62 changes: 62 additions & 0 deletions charts/zfs-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "zfs-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 "zfs-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 "zfs-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "zfs-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "zfs-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
25 changes: 25 additions & 0 deletions charts/zfs-exporter/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
kind: ConfigMap
metadata:
labels:
{{- include "zfs-exporter.labels" . | nindent 4 }}
name: zfspv-bin
data:
zfs: |
#!/bin/sh
if [ -x /host/sbin/zfs ]; then
chroot /host /sbin/zfs "$@"
elif [ -x /host/usr/sbin/zfs ]; then
chroot /host /usr/sbin/zfs "$@"
else
chroot /host "zfs" "$@"
fi
zpool: |
#!/bin/sh
if [ -x /host/sbin/zpool ]; then
chroot /host /sbin/zpool "$@"
elif [ -x /host/usr/sbin/zpool ]; then
chroot /host /usr/sbin/zpool "$@"
else
chroot /host "zpool" "$@"
fi
87 changes: 87 additions & 0 deletions charts/zfs-exporter/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "zfs-exporter.fullname" . }}
labels:
{{- include "zfs-exporter.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "zfs-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "zfs-exporter.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "zfs-exporter.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- with .Values.priorityClassName }}
priorityClassName: {{ . | quote }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 9134
hostPort: 9134
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
volumeMounts:
- name: device-dir
mountPath: /dev
- name: chroot-zfs
mountPath: /sbin/zfs
subPath: zfs
- name: chroot-zfs
mountPath: /sbin/zpool
subPath: zpool
- name: host-root
mountPath: /host
mountPropagation: "HostToContainer"
readOnly: true
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- hostPath:
path: /dev
type: Directory
name: device-dir
- configMap:
defaultMode: 365
name: zfspv-bin
name: chroot-zfs
- hostPath:
path: /
type: Directory
name: host-root
16 changes: 16 additions & 0 deletions charts/zfs-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "zfs-exporter.fullname" . }}
labels:
{{- include "zfs-exporter.labels" . | nindent 4 }}
spec:
type: ClusterIP
port: 9134
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "zfs-exporter.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/zfs-exporter/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "zfs-exporter.serviceAccountName" . }}
labels:
{{- include "zfs-exporter.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/zfs-exporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
{{- include "zfs-exporter.labels" . | nindent 4 }}
{{- with .Values.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ include "zfs-exporter.fullname" . }}
spec:
endpoints:
- port: http
scheme: http
selector:
matchLabels:
{{- include "zfs-exporter.selectorLabels" . | nindent 6 }}
48 changes: 48 additions & 0 deletions charts/zfs-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
image:
repository: enix/zfs-exporter
pullPolicy: IfNotPresent
tag: "v2.3.4"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}

securityContext:
privileged: true
allowPrivilegeEscalation: true

service:
type: ClusterIP
port: 9134

resources:
limits:
cpu: 100m
memory: 64Mi
requests:
cpu: 30m
memory: 64Mi

priorityClassName: ""

nodeSelector: {}

tolerations: {}

affinity: {}

serviceMonitor:
additionalLabels: {}

0 comments on commit ee113fe

Please sign in to comment.