diff --git a/helm/flowforge/README.md b/helm/flowforge/README.md index a1b53413..c37c8f7c 100644 --- a/helm/flowforge/README.md +++ b/helm/flowforge/README.md @@ -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]`) diff --git a/helm/flowforge/templates/broker.yaml b/helm/flowforge/templates/broker.yaml index 74aa9df4..df962fc7 100644 --- a/helm/flowforge/templates/broker.yaml +++ b/helm/flowforge/templates/broker.yaml @@ -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 @@ -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 @@ -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 diff --git a/helm/flowforge/tests/broker_test.yaml b/helm/flowforge/tests/broker_test.yaml new file mode 100644 index 00000000..d33c12a8 --- /dev/null +++ b/helm/flowforge/tests/broker_test.yaml @@ -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 diff --git a/helm/flowforge/values.schema.json b/helm/flowforge/values.schema.json index 484dc241..5307475f 100644 --- a/helm/flowforge/values.schema.json +++ b/helm/flowforge/values.schema.json @@ -368,6 +368,9 @@ }, "createMetricsUser": { "type": "boolean" + }, + "image": { + "type": "string" } }, "required": [ diff --git a/helm/flowforge/values.yaml b/helm/flowforge/values.yaml index 6506f6f9..e5914282 100644 --- a/helm/flowforge/values.yaml +++ b/helm/flowforge/values.yaml @@ -19,6 +19,7 @@ forge: podLabels: {} broker: enabled: false + image: iegomez/mosquitto-go-auth teamBroker: enabled: false createMetricsUser: false