Add mqtt chart.
All checks were successful
ci/woodpecker/push/mqtt Pipeline was successful

This commit is contained in:
Alex Manning 2023-03-02 21:06:05 +00:00
parent faa6e0f65d
commit 72247c9403
13 changed files with 306 additions and 5 deletions

View file

@ -1,6 +1,6 @@
---
when:
path: "charts/matrix-appservice-irc/*"
path: "charts/matrix-appservice-irc/**"
branches:
- main
pipeline:

View file

@ -1,6 +1,6 @@
---
when:
path: "charts/mautrix-facebook/*"
path: "charts/mautrix-facebook/**"
branches:
- main
pipeline:

View file

@ -1,6 +1,6 @@
---
when:
path: "charts/mautrix-instagram/*"
path: "charts/mautrix-instagram/**"
branches:
- main
pipeline:

View file

@ -1,6 +1,6 @@
---
when:
path: "charts/mautrix-whatsapp/*"
path: "charts/mautrix-whatsapp/**"
branches:
- main
pipeline:

13
.woodpecker/mqtt.yaml Normal file
View file

@ -0,0 +1,13 @@
---
when:
path: "charts/mqtt/**"
branches:
- main
pipeline:
package:
image: "docker.io/alpine/helm:latest"
secrets: [helm_user, helm_password, helm_repo]
commands:
- helm plugin install https://github.com/chartmuseum/helm-push
- helm repo add therepo $HELM_REPO --username $HELM_USER --password $HELM_PASSWORD
- helm cm-push charts/mqtt therepo

View file

@ -1,6 +1,6 @@
---
when:
path: "charts/node-red/*"
path: "charts/node-red/**"
branches:
- main
pipeline:

23
charts/mqtt/.helmignore Normal file
View file

@ -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/

24
charts/mqtt/Chart.yaml Normal file
View file

@ -0,0 +1,24 @@
apiVersion: v2
name: mqtt
description: A Helm chart for Kubernetes
# 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"

View file

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

View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "mqtt.fullname" . }}-mqtt-mosquittoconf
labels:
{{- include "mqtt.labels" . | nindent 4 }}
data:
mosquitto.conf: |
listener 1883
allow_anonymous true

View file

@ -0,0 +1,68 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mqtt.fullname" . }}-mqtt
labels:
{{- include "mqtt.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
hass.kube.a09.uk/automationService: mqtt
{{- include "mqtt.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/mqtt/configmap.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
hass.kube.a09.uk/automationService: mqtt
{{- include "mqtt.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
priorityClassName: {{ .Values.priorityClassName }}
containers:
- name: {{ .Chart.Name }}-mqtt
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: mqtt
containerPort: 1883
protocol: TCP
livenessProbe:
tcpSocket:
port: mqtt
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: mosquittoconf
mountPath: "mosquitto/config"
readOnly: true
{{- 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:
- name: mosquittoconf
configMap:
name: {{ include "mqtt.fullname" . }}-mqtt-mosquittoconf
items:
- key: "mosquitto.conf"
path: "mosquitto.conf"

View file

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mqtt.fullname" . }}-mqtt
labels:
{{- include "mqtt.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: 1883
targetPort: mqtt
protocol: TCP
name: mqtt
{{- with .Values.service.nodePort }}
nodePort: {{ . }}
{{- end }}
selector:
hass.kube.a09.uk/automationService: mqtt
{{- include "mqtt.selectorLabels" . | nindent 4 }}

82
charts/mqtt/values.yaml Normal file
View file

@ -0,0 +1,82 @@
# Default values for mqtt.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: nginx
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
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: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
nodeSelector: {}
tolerations: []
affinity: {}