Skip to content

Commit ffb9d42

Browse files
authored
Add MQTT Broker to Basyx Helm Chart (eclipse-basyx#690)
* added mqtt dependency chart * changed Chart.yaml for mqtt * changed chart name of mqtt * fix: removed unused code
1 parent a97e4a2 commit ffb9d42

File tree

11 files changed

+699
-0
lines changed

11 files changed

+699
-0
lines changed

examples/cloud/Chart.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ dependencies:
2727
version: "0.0.1"
2828
repository: file://dependency_charts/aas-web-ui
2929
condition: aas-web-ui.enabled
30+
- name: mqtt
31+
version: "0.0.1"
32+
repository: file://dependency_charts/mqtt
33+
condition: mqtt.enabled
3034
- name: mongodb
3135
version: "14.5.0"
3236
repository: https://charts.bitnami.com/bitnami
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#################################################################################
2+
# Copyright (c) 2025 SAP SE
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License, Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0.
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
#
17+
# SPDX-License-Identifier: Apache-2.0
18+
#################################################################################
19+
20+
apiVersion: v2
21+
name: mqtt
22+
description: A Helm chart for running Eclipse Mosquitto
23+
type: application
24+
version: 0.0.1
25+
appVersion: 2.0.21
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "mqtt.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 "mqtt.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 "mqtt.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "mqtt.labels" -}}
37+
helm.sh/chart: {{ include "mqtt.chart" . }}
38+
{{ include "mqtt.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 "mqtt.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "mqtt.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 "mqtt.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "mqtt.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#################################################################################
2+
# Copyright (c) 2025 SAP SE
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License, Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0.
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
#
17+
# SPDX-License-Identifier: Apache-2.0
18+
#################################################################################
19+
20+
{{- $fullName := include "mqtt.fullname" . }}
21+
{{- $labels := include "mqtt.labels" . }}
22+
{{- $ports := .Values.ports }}
23+
24+
{{- range .Values.apirules}}
25+
{{- if .enabled }}
26+
{{- $annotations := .annotations | default dict }}
27+
---
28+
apiVersion: gateway.kyma-project.io/v2alpha1
29+
kind: APIRule
30+
metadata:
31+
name: {{ $fullName }}-{{ .type }}
32+
labels:
33+
{{- $labels | nindent 4 }}
34+
{{- with $annotations }}
35+
annotations:
36+
{{- toYaml . | nindent 4 }}
37+
{{- end }}
38+
spec:
39+
{{- if .gateway }}
40+
gateway: {{ .gateway }}
41+
{{- else }}
42+
{{ fail "Gateway not specified. Failing the pipeline." }}
43+
{{- end }}
44+
{{- if .hostname }}
45+
{{- if .corsPolicy }}
46+
corsPolicy:
47+
{{- with .corsPolicy }}
48+
{{- toYaml . | nindent 4 }}
49+
{{- end }}
50+
{{- end }}
51+
hosts:
52+
- {{ .hostname }}
53+
rules:
54+
{{- $type := .type }}
55+
{{- range $key, $port := $ports }}
56+
{{- if (eq $key $type)}}
57+
- path: /*
58+
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "TRACE", "HEAD"]
59+
noAuth: true
60+
service:
61+
name: {{ $fullName }}
62+
port: {{ .port }}
63+
{{- end }}
64+
{{- end }}
65+
{{- end }}
66+
{{- end }}
67+
{{- end }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#################################################################################
2+
# Copyright (c) 2025 SAP SE
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License, Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0.
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
#
17+
# SPDX-License-Identifier: Apache-2.0
18+
#################################################################################
19+
20+
apiVersion: v1
21+
kind: ConfigMap
22+
metadata:
23+
name: {{ include "mqtt.fullname" . }}
24+
labels: {{- include "mqtt.labels" . | nindent 4 }}
25+
data:
26+
mosquitto.conf: |-
27+
listener {{ .Values.ports.mqtt.port }}
28+
{{- if .Values.websockets.enabled }}
29+
listener {{ .Values.ports.websockets.port }}
30+
protocol websockets
31+
{{- end }}
32+
{{- if .Values.auth.enabled }}
33+
allow_anonymous false
34+
password_file /mosquitto/config/passwords.conf
35+
acl_file /mosquitto/config/acl.conf
36+
{{- else }}
37+
allow_anonymous true
38+
{{- end }}
39+
{{- if .Values.persistence.enabled }}
40+
persistence true
41+
persistence_location {{ .Values.persistence.mountPath }}
42+
autosave_interval 1800
43+
{{- end }}
44+
log_dest stdout
45+
log_type all
46+
{{- if .Values.auth.enabled }}
47+
acl.conf: |-
48+
{{- range $user := .Values.auth.users }}
49+
user {{ $user.username }}
50+
{{- range $acl := $user.acl }}
51+
topic {{ $acl.access }} {{ $acl.topic }}
52+
{{- end }}
53+
{{- end }}
54+
passwords.conf: |-
55+
{{- range $value := .Values.auth.users }}
56+
{{ $value.username }}:{{ $value.password }}
57+
{{- end }}
58+
{{- end }}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#################################################################################
2+
# Copyright (c) 2025 SAP SE
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License, Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0.
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
#
17+
# SPDX-License-Identifier: Apache-2.0
18+
#################################################################################
19+
20+
apiVersion: apps/v1
21+
kind: Deployment
22+
metadata:
23+
name: {{ include "mqtt.fullname" . }}
24+
labels:
25+
{{- include "mqtt.labels" . | nindent 4 }}
26+
spec:
27+
replicas: {{ .Values.replicaCount }}
28+
selector:
29+
matchLabels:
30+
{{- include "mqtt.selectorLabels" . | nindent 6 }}
31+
template:
32+
metadata:
33+
{{- with .Values.podAnnotations }}
34+
annotations:
35+
{{- toYaml . | nindent 8 }}
36+
{{- end }}
37+
labels:
38+
{{- include "mqtt.labels" . | nindent 8 }}
39+
{{- with .Values.podLabels }}
40+
{{- toYaml . | nindent 8 }}
41+
{{- end }}
42+
spec:
43+
{{- with .Values.imagePullSecrets }}
44+
imagePullSecrets:
45+
{{- toYaml . | nindent 8 }}
46+
{{- end }}
47+
securityContext:
48+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
49+
containers:
50+
- name: {{ .Chart.Name }}
51+
securityContext:
52+
{{- toYaml .Values.securityContext | nindent 12 }}
53+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
54+
imagePullPolicy: {{ .Values.image.pullPolicy }}
55+
ports:
56+
- name: mqtt
57+
containerPort: {{ .Values.ports.mqtt.port }}
58+
protocol: {{ .Values.ports.mqtt.protocol }}
59+
{{- if .Values.websockets.enabled }}
60+
- name: websockets
61+
containerPort: {{ .Values.ports.websockets.port }}
62+
protocol: {{ .Values.ports.websockets.protocol }}
63+
{{- end }}
64+
livenessProbe:
65+
{{- toYaml .Values.livenessProbe | nindent 12 }}
66+
readinessProbe:
67+
{{- toYaml .Values.readinessProbe | nindent 12 }}
68+
resources:
69+
{{- toYaml .Values.resources | nindent 12 }}
70+
volumeMounts:
71+
- name: config
72+
mountPath: /mosquitto/config/mosquitto.conf
73+
subPath: mosquitto.conf
74+
- name: data
75+
mountPath: {{ .Values.persistence.mountPath }}
76+
subPath: {{ .Values.persistence.subPath }}
77+
{{- if .Values.auth.enabled }}
78+
- name: password
79+
mountPath: /mosquitto/config/passwords.conf
80+
subPath: passwords.conf
81+
- name: acl
82+
mountPath: /mosquitto/config/acl.conf
83+
subPath: acl.conf
84+
{{- end }}
85+
{{- with .Values.volumeMounts }}
86+
{{- toYaml . | nindent 12 }}
87+
{{- end }}
88+
volumes:
89+
- name: config
90+
configMap:
91+
name: {{ include "mqtt.fullname" . }}
92+
- name: data
93+
{{- if .Values.persistence.enabled }}
94+
persistentVolumeClaim:
95+
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ include "mqtt.fullname" . }}{{- end }}
96+
{{- else }}
97+
emptyDir: {}
98+
{{- end }}
99+
{{- if .Values.auth.enabled }}
100+
- name: password
101+
configMap:
102+
name: {{ include "mqtt.fullname" . }}
103+
- name: acl
104+
configMap:
105+
name: {{ include "mqtt.fullname" . }}
106+
{{- end }}
107+
{{- with .Values.volumes }}
108+
{{- toYaml . | nindent 8 }}
109+
{{- end }}
110+
{{- with .Values.nodeSelector }}
111+
nodeSelector:
112+
{{- toYaml . | nindent 8 }}
113+
{{- end }}
114+
{{- with .Values.affinity }}
115+
affinity:
116+
{{- toYaml . | nindent 8 }}
117+
{{- end }}
118+
{{- with .Values.tolerations }}
119+
tolerations:
120+
{{- toYaml . | nindent 8 }}
121+
{{- end }}

0 commit comments

Comments
 (0)