Skip to content

Commit 934a2a0

Browse files
committed
feat(charts): add helm chart for fritzbox-exporter
1 parent 3047562 commit 934a2a0

File tree

7 files changed

+222
-0
lines changed

7 files changed

+222
-0
lines changed

charts/fritzbox-exporter/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
type: application
3+
name: fritzbox-exporter
4+
description: A Helm chart for fritzbox-exporter
5+
version: 0.0.1
6+
appVersion: "1.0"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
1. Get the application URL by running these commands:
2+
{{- if contains "NodePort" .Values.service.type }}
3+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "fritzbox-exporter.fullname" . }})
4+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
5+
echo http://$NODE_IP:$NODE_PORT
6+
{{- else if contains "LoadBalancer" .Values.service.type }}
7+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
8+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "fritzbox-exporter.fullname" . }}'
9+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "fritzbox-exporter.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
10+
echo http://$SERVICE_IP:{{ .Values.ports.metrics.port }}
11+
{{- else if contains "ClusterIP" .Values.service.type }}
12+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "fritzbox-exporter.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
13+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
14+
echo "Visit http://127.0.0.1:8765 to use your application"
15+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8765:$CONTAINER_PORT
16+
{{- end }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "fritzbox-exporter.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "fritzbox-exporter.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "fritzbox-exporter.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "fritzbox-exporter.labels" -}}
37+
helm.sh/chart: {{ include "fritzbox-exporter.chart" . }}
38+
{{ include "fritzbox-exporter.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "fritzbox-exporter.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "fritzbox-exporter.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "fritzbox-exporter.serviceAccountName" -}}
57+
{{- default "default" .Values.serviceAccount.name }}
58+
{{- end }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{{- if .Values.deployment.enabled -}}
2+
apiVersion: apps/v1
3+
kind: {{ .Values.deployment.kind }}
4+
metadata:
5+
name: {{ include "fritzbox-exporter.fullname" . }}
6+
labels:
7+
{{- include "fritzbox-exporter.labels" . | nindent 4 }}
8+
{{- with .Values.deployment.labels }}
9+
{{ toYaml . | indent 4 }}
10+
{{- end }}
11+
spec:
12+
{{- if .Values.deployment.replicas }}
13+
replicas: {{ .Values.deployment.replicas }}
14+
{{- end }}
15+
selector:
16+
matchLabels:
17+
{{- include "fritzbox-exporter.selectorLabels" . | nindent 6 }}
18+
template:
19+
metadata:
20+
{{- with .Values.deployment.annotations }}
21+
annotations:
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
labels:
25+
{{- include "fritzbox-exporter.selectorLabels" . | nindent 8 }}
26+
spec:
27+
serviceAccountName: {{ include "fritzbox-exporter.serviceAccountName" . }}
28+
containers:
29+
- name: {{ .Chart.Name }}
30+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
31+
imagePullPolicy: {{ .Values.image.pullPolicy }}
32+
ports:
33+
{{- range $key, $val := .Values.ports }}
34+
{{- if $val.enabled }}
35+
- name: {{ $key | quote }}
36+
containerPort: {{ $val.port }}
37+
protocol: {{ $val.protocol | default "TCP" }}
38+
{{- end }}
39+
{{- end }}
40+
env:
41+
{{- range $i, $val := .Values.env }}
42+
- name: {{ $val.name | quote }}
43+
value: {{ $val.value | quote }}
44+
{{- end }}
45+
{{- if .Values.ports.metrics.enabled -}}
46+
livenessProbe:
47+
httpGet:
48+
path: /metrics
49+
port: metrics
50+
readinessProbe:
51+
httpGet:
52+
path: /metrics
53+
port: metrics
54+
{{- end }}
55+
resources: {{ if not .Values.resources -}}{}{{- end }}
56+
{{- if .Values.resources }}
57+
{{- toYaml .Values.resources | nindent 12 }}
58+
{{- end }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{- if .Values.service.enabled -}}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ include "fritzbox-exporter.fullname" . }}
6+
labels:
7+
{{- include "fritzbox-exporter.labels" . | nindent 4 }}
8+
{{- with .Values.service.labels }}
9+
{{ toYaml . | indent 4 }}
10+
{{- end }}
11+
{{- with .Values.deployment.annotations }}
12+
annotations:
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
spec:
16+
type: {{ .Values.service.type }}
17+
ports:
18+
{{- range $key, $val := .Values.ports }}
19+
{{- if $val.enabled }}
20+
- name: {{ $key | quote }}
21+
port: {{ $val.port }}
22+
targetPort: {{ $key | quote }}
23+
protocol: {{ $val.protocol | default "TCP" }}
24+
{{- end }}
25+
{{- end }}
26+
selector:
27+
{{- include "fritzbox-exporter.selectorLabels" . | nindent 4 }}
28+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: "{{ include "fritzbox-exporter.fullname" . }}-test-connection"
5+
labels:
6+
{{- include "fritzbox-exporter.labels" . | nindent 4 }}
7+
annotations:
8+
"helm.sh/hook": test
9+
spec:
10+
containers:
11+
- name: wget
12+
image: busybox
13+
command: ['wget']
14+
args: ['{{ include "fritzbox-exporter.fullname" . }}:{{ .Values.ports.metrics.port }}']
15+
restartPolicy: Never

charts/fritzbox-exporter/values.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
image:
2+
repository: sealife/fritzbox-exporter
3+
tag: 1.0
4+
pullPolicy: IfNotPresent
5+
6+
nameOverride: ""
7+
fullnameOverride: ""
8+
9+
deployment:
10+
enabled: true
11+
kind: Deployment
12+
replicas: 1
13+
annotations: {}
14+
labels: {}
15+
16+
service:
17+
enable: true
18+
type: ClusterIP
19+
annotations: {}
20+
labels: {}
21+
22+
env:
23+
- name: TZ
24+
value: UTC
25+
26+
ports:
27+
metrics:
28+
enabled: true
29+
port: 8765
30+
protocol: TCP
31+
32+
serviceAccount:
33+
name: ''
34+
35+
resources: {}
36+
# requests:
37+
# cpu: 100m
38+
# memory: 128Mi
39+
# limits:
40+
# cpu: 100m
41+
# memory: 128Mi

0 commit comments

Comments
 (0)