Add aaisp-to-mqtt chart

This commit is contained in:
2020-05-04 12:05:25 +01:00
parent 0ab91c1e82
commit e90e2b8e07
6 changed files with 254 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "aaisp-to-mqtt.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 "aaisp-to-mqtt.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 "aaisp-to-mqtt.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "aaisp-to-mqtt.labels" -}}
app.kubernetes.io/name: {{ include "aaisp-to-mqtt.name" . }}
helm.sh/chart: {{ include "aaisp-to-mqtt.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "aaisp-to-mqtt.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "aaisp-to-mqtt.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,90 @@
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: {{ include "aaisp-to-mqtt.fullname" . }}-cronjob
{{- if .Values.deploymentAnnotations }}
annotations:
{{- range $key, $value := .Values.deploymentAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "aaisp-to-mqtt.name" . }}
helm.sh/chart: {{ include "aaisp-to-mqtt.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ include "aaisp-to-mqtt.name" . }}
spec:
concurrencyPolicy: {{ .Values.cronjob.concurrencyPolicy }}
failedJobsHistoryLimit: {{ .Values.cronjob.failedJobsHistoryLimit }}
jobTemplate:
spec:
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "aaisp-to-mqtt.name" . }}
helm.sh/chart: {{ include "aaisp-to-mqtt.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ include "aaisp-to-mqtt.name" . }}
spec:
restartPolicy: Never
{{- if (default .Values.image.pullSecrets .Values.cronjob.image.pullSecrets) }}
imagePullSecrets:
{{- range (default .Values.image.pullSecrets .Values.cronjob.image.pullSecrets) }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ default .Values.image.repository .Values.cronjob.image.repository }}:{{ default .Values.image.tag .Values.cronjob.image.tag }}"
imagePullPolicy: {{ default .Values.image.pullPolicy .Values.cronjob.image.pullPolicy }}
env:
- name: AAISP_USERNAME
valueFrom:
secretKeyRef:
name: {{- default "aaisp-to-mqtt-secret" .Values.existingSecretName }}
key: aaisp.username
- name: AAISP_PASSWORD
valueFrom:
secretKeyRef:
name: {{- default "aaisp-to-mqtt-secret" .Values.existingSecretName }}
key: aaisp.password
- name: MQTT_BROKER
value: {{ .Values.mqtt.broker }}
- name: MQTT_PORT
value: {{- default 1883 .Values.mqtt.port }}
{{- .Values.mqtt.authenticated }}
- name: MQTT_USERNAME
valueFrom:
secretKeyRef:
name: {{- default "aaisp-to-mqtt-secret" .Values.existingSecretName }}
key: mqtt.username
- name: MQTT_PASSWORD
valueFrom:
secretKeyRef:
name: {{- default "aaisp-to-mqtt-secret" .Values.existingSecretName }}
key: mqtt.password
{{- end }}
- name: MQTT_TOPIC_PREFIX
value: {{ default "aaisp" .Values.mqtt.topicPrefix }}
resources:
{{ toYaml (default .Values.resources .Values.cronjob.resources) | indent 16 }}
{{- with (default .Values.nodeSelector .Values.cronjob.nodeSelector) }}
nodeSelector:
{{ toYaml . | indent 12 }}
{{- end }}
{{- with (default .Values.affinity .Values.cronjob.affinity) }}
affinity:
{{ toYaml . | indent 12 }}
{{- end }}
{{- with (default .Values.tolerations .Values.cronjob.tolerations) }}
tolerations:
{{ toYaml . | indent 12 }}:
{{- end }}
schedule: {{ .Values.schedule | quote }}
successfulJobsHistoryLimit: {{ .Values.cronjob.successfulJobsHistoryLimit }}
failedJobsHistoryLimit: {{ .Values.cronjob.failedJobsHistoryLimit }}
concurrencyPolicy: Forbid
{{- if .Values.cronjob.startingDeadlineSeconds }}
startingDeadlineSeconds: {{ .Values.cronjob.startingDeadlineSeconds }}
{{- end }}

View File

@@ -0,0 +1,20 @@
{{- if Not(.Values.cronjob.existingSecretName) }}
---
apiVersion: v1
kind: Secret
metadata:
name: aaisp-to-mqtt-secret
labels:
app.kubernetes.io/name: {{ include "aaisp-to-mqtt.name" . }}
helm.sh/chart: {{ include "aaisp-to-mqtt.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ include "aaisp-to-mqtt.name" . }}
type: Opaque
data:
aaisp.username: {{ .Values.aaisp.username }}
aaisp.password: {{ .Values.aaisp.password }}
{{- if .Values.mqtt.authenticated }}
mqtt.username: {{ .Values.mqtt.username }}
mqtt.password: {{ .Values.mqtt.password }}
{{- end }}
{{- end }}