Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add possibility to customize domain for MQTT broker #359

Merged
merged 10 commits into from
Apr 8, 2024
3 changes: 2 additions & 1 deletion helm/flowforge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ For other values please refer to the documentation below.

- `forge.image` supply a fully qualified container image for the forge app (default `forge.registry`/flowforge/forge-k8s:<App Version>)
- `forge.domain` the domain instances will be hosted on
- `forge.entryPoint` if the admin app is hosted on a different domain
- `forge.entryPoint` the custom Fully Qualified Domain Name (FQDN) for the admin app (default `forge.[forge.domain]`)
- `forge.https` is the Forge App accessed via HTTPS (default `true`)
- `forge.registry` the hostname for the container registry to find Project stacks (default Docker Hub)
- `forge.localPostrgresql` Deploy a PostgreSQL v14 Database into Kubernetes cluster (default `true`)
Expand Down Expand Up @@ -85,6 +85,7 @@ To use STMP to send email
- `forge.broker.enabled` (default `false`)
- `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]`)
- `forge.broker.affinity` allows to configure [affinity or anti-affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) for the broker pod
- `forge.broker.resources` allows to configure [resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) for the broker container
- `forge.broker.podSecurityContext` allows to configure [securityContext](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) for the broker pod
Expand Down
12 changes: 12 additions & 0 deletions helm/flowforge/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,15 @@ password: {{ .Values.postgresql.auth.password | b64enc | quote }}
postgres-password: {{ .Values.postgresql.auth.postgresPassword | b64enc | quote }}
{{- end -}}
{{- end -}}


{{/*
Configure broker domain
*/}}
{{- define "forge.brokerDomain" -}}
{{- if (((.Values.forge).broker).hostname) -}}
{{ .Values.forge.broker.hostname }}
{{- else -}}
{{ printf "%s.%s" "mqtt" .Values.forge.domain }}
{{- end -}}
{{- end -}}
10 changes: 5 additions & 5 deletions helm/flowforge/templates/broker-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ metadata:
cert-manager.io/cluster-issuer: {{ $.Values.ingress.certManagerIssuer }}
{{- end }}
{{- if and .Values.forge.broker.enabled .Values.forge.broker.ingress (hasKey .Values.forge.broker.ingress "annotations") }}
{{ toYaml .Values.forge.broker.ingress.annotations | replace "{{ instanceHost }}" $brokerHostname | replace "{{ serviceName }}" "flowforge-broker" | indent 4 }}
{{ toYaml .Values.forge.broker.ingress.annotations | replace "{{ instanceHost }}" "{{ include forge.brokerDomain . }}" | replace "{{ serviceName }}" "flowforge-broker" | indent 4 }}
{{- end }}
spec:
{{- if $.Values.ingress.className }}
ingressClassName: {{ $.Values.ingress.className }}
{{- end }}
rules:
- host: mqtt.{{ .Values.forge.domain }}
- host: {{ include "forge.brokerDomain" . }}
http:
paths:
- pathType: Prefix
Expand All @@ -31,7 +31,7 @@ spec:
{{- if .Values.ingress.certManagerIssuer }}
tls:
- hosts:
- mqtt.{{ .Values.forge.domain }}
secretName: mqtt.{{ .Values.forge.domain }}
- {{ include "forge.brokerDomain" . }}
secretName: {{ include "forge.brokerDomain" . }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion helm/flowforge/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ data:
{{ if .Values.forge.broker.public_url -}}
public_url: {{ .Values.forge.broker.public_url }}
{{ else -}}
public_url: ws{{- if .Values.forge.https -}}s{{- end -}}://mqtt.{{ .Values.forge.domain }}
public_url: ws{{- if .Values.forge.https -}}s{{- end -}}://{{ include "forge.brokerDomain" . }}
{{ end -}}
{{- end }}
logging:
Expand Down
3 changes: 3 additions & 0 deletions helm/flowforge/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@
"public_url": {
"type": "string"
},
"hostname": {
"type": "string"
},
"affinity": {
"type": "object"
},
Expand Down
Loading