Skip to content

Commit

Permalink
fix: Allow MQTT broker container config (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
hardillb authored Nov 22, 2024
1 parent f9a2e7d commit fb2038e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 3 deletions.
1 change: 1 addition & 0 deletions helm/flowforge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ To use STMP to send email
### MQTT Broker

- `forge.broker.enabled` (default `false`)
- `forge.broker.image` Allows the mosquitto broker container image to be overidden (default `iegomez/mosquitto-go-auth`)
- `forge.broker.url` URL to access the broker from inside the cluster (default `mqtt://flowforge-broker.[namespace]:1883`)
- `forge.broker.public_url` URL to access the broker from outside the cluster (default `ws://mqtt.[forge.domain]`, uses `wss://` if `forge.https` is `true`)
- `forge.broker.hostname` the custom Fully Qualified Domain Name (FQDN) where the broker will be hosted (default `mqtt.[forge.domain]`)
Expand Down
6 changes: 3 additions & 3 deletions helm/flowforge/templates/broker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
{{- toYaml .Values.forge.broker.podSecurityContext | nindent 8 }}
containers:
- name: broker
image: iegomez/mosquitto-go-auth
image: {{ .Values.forge.broker.image }}
imagePullPolicy: Always
volumeMounts:
- name: config
Expand Down Expand Up @@ -127,7 +127,7 @@ spec:
affinity: {{ toYaml .Values.forge.broker.affinity | nindent 8 }}
{{- end }}
{{- end }}
{{- if eq .Values.forge.broker.enabled true -}}
{{- if .Values.forge.broker.enabled }}
---
apiVersion: v1
kind: Service
Expand All @@ -148,7 +148,7 @@ spec:
selector:
{{- if and ( eq .Values.forge.broker.enabled true) ( eq .Values.forge.broker.teamBroker.enabled false ) -}}
{{- include "forge.brokerSelectorLabels" . | nindent 4 }}
{{- else -}}
{{- else }}
apps.emqx.io/db-role: core
apps.emqx.io/instance: emqx
apps.emqx.io/managed-by: emqx-operator
Expand Down
53 changes: 53 additions & 0 deletions helm/flowforge/tests/broker_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: test broker deployment
templates:
- broker.yaml
- broker-config.yaml
set:
forge.domain: "chart-unit-tests.com"
forge.broker.enabled: true
tests:
- it: should create a mosquitto broker deployment
template: broker.yaml
documentIndex: 0
asserts:
- isKind:
of: Deployment
- equal:
path: spec.template.spec.containers[?(@.name == "broker")].image
value: iegomez/mosquitto-go-auth
- lengthEqual:
path: spec.template.spec.containers
count: 1

- it: should create a broker service for mosquitto broker deployment
template: broker.yaml
documentIndex: 1
asserts:
- isKind:
of: Service
- equal:
path: spec.selector
value:
app: flowforge-broker
- not: true
equal:
path: spec.selector
value: apps.emqx.io/instance

- it: should create a broker service for emqx deployment
template: broker.yaml
documentIndex: 0
set:
forge.broker.teamBroker.enabled: true
asserts:
- isKind:
of: Service
- notExists:
path: spec.selector.app
- equal:
path: spec.selector
value:
apps.emqx.io/db-role: core
apps.emqx.io/instance: emqx
apps.emqx.io/managed-by: emqx-operator
3 changes: 3 additions & 0 deletions helm/flowforge/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@
},
"createMetricsUser": {
"type": "boolean"
},
"image": {
"type": "string"
}
},
"required": [
Expand Down
1 change: 1 addition & 0 deletions helm/flowforge/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ forge:
podLabels: {}
broker:
enabled: false
image: iegomez/mosquitto-go-auth
teamBroker:
enabled: false
createMetricsUser: false
Expand Down

0 comments on commit fb2038e

Please sign in to comment.