generated from AMRC-FactoryPlus/acs-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create an edge MQTT broker helm chart (#379)
Create a new edge helm chart which deploys an MQTT broker. This broker is exposed to the cluster as service; the chart also provides the option to expose it on an external IP. No security is currently implemented, beyond a default of `internalTrafficPolicy: Local` which should prevent off-node pods from contacting the broker but is not intended as a security feature.
- Loading branch information
Showing
8 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v2 | ||
name: mqtt-broker | ||
version: "0.0.1" | ||
description: "ACS edge MQTT broker" |
12 changes: 12 additions & 0 deletions
12
edge-helm-charts/charts/mqtt-broker/templates/_helpers.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{- define "acs.image" -}} | ||
{{- $root := index . 0 -}} | ||
{{- $key := index . 1 -}} | ||
{{- $image := $root.Values.image -}} | ||
{{- $spec := merge (get $image $key) $image.default -}} | ||
image: "{{ $spec.registry }}/{{ $spec.repository }}:{{ $spec.tag }}" | ||
imagePullPolicy: {{ $spec.pullPolicy }} | ||
{{- end }} | ||
|
||
{{- define "acs.k8sname" }} | ||
{{- .Values.name | lower | replace "_" "-" }} | ||
{{- end }} |
52 changes: 52 additions & 0 deletions
52
edge-helm-charts/charts/mqtt-broker/templates/mqtt-broker.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{{- $k8sname := include "acs.k8sname" . }} | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ .Chart.Name }}-{{ $k8sname }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
factory-plus.app: {{ .Chart.Name }} | ||
factory-plus.uuid: {{ .Values.uuid }} | ||
factory-plus.name: {{ .Values.name }} | ||
spec: | ||
replicas: 1 | ||
strategy: | ||
type: Recreate | ||
selector: | ||
matchLabels: | ||
factory-plus.app: {{ .Chart.Name }} | ||
factory-plus.uuid: {{ .Values.uuid }} | ||
template: | ||
metadata: | ||
labels: | ||
factory-plus.app: {{ .Chart.Name }} | ||
factory-plus.uuid: {{ .Values.uuid }} | ||
factory-plus.name: {{ .Values.name }} | ||
spec: | ||
{{ if .Values.hostname }} | ||
nodeSelector: | ||
kubernetes.io/hostname: {{ .Values.hostname | quote }} | ||
tolerations: {{ .Values.tolerations.specific | toYaml | nindent 8 }} | ||
{{ else }} | ||
tolerations: {{ .Values.tolerations.floating | toYaml | nindent 8 }} | ||
{{ end }} | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: {{ .Chart.Name }}-{{ $k8sname }} | ||
containers: | ||
- name: mqtt-broker | ||
{{ list . "mosquitto" | include "acs.image" | indent 10 }} | ||
volumeMounts: | ||
- mountPath: /mosquitto/config | ||
name: config | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
namespace: {{ .Release.Namespace }} | ||
name: {{ .Chart.Name }}-{{ $k8sname }} | ||
data: | ||
mosquitto.conf: | | ||
listener 1883 | ||
allow_anonymous true |
18 changes: 18 additions & 0 deletions
18
edge-helm-charts/charts/mqtt-broker/templates/service.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{- $k8sname := include "acs.k8sname" . }} | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
namespace: {{ .Release.Namespace }} | ||
name: {{ .Chart.Name }}-{{ $k8sname }} | ||
spec: | ||
selector: | ||
factory-plus.app: {{ .Chart.Name }} | ||
factory-plus.uuid: {{ .Values.uuid }} | ||
{{- with .Values.expose }} | ||
internalTrafficPolicy: {{ .internalTrafficPolicy }} | ||
ports: | ||
- name: mqtt | ||
port: {{ .port }} | ||
targetPort: 1883 | ||
externalIPs: {{ .externalIPs }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This is required | ||
# uuid: 12345 | ||
# This deploys to a specific host | ||
#hostname: foo | ||
image: | ||
default: | ||
pullPolicy: IfNotPresent | ||
mosquitto: | ||
registry: docker.io | ||
repository: eclipse-mosquitto | ||
tag: "2.0" | ||
tolerations: | ||
# Tolerations to apply to pods deployed to a specific host | ||
specific: | ||
- key: factoryplus.app.amrc.co.uk/specialised | ||
operator: Exists | ||
# Tolerations to apply to floating pods | ||
floating: [] | ||
# Whether to expose the broker externally | ||
expose: | ||
# Expose on an existing external IP | ||
externalIPs: [] | ||
# Port to expose on | ||
port: 1883 | ||
# How to route cluster-internal traffic. Setting this to Local will | ||
# prevent pods on different nodes from contacting the service. | ||
internalTrafficPolicy: Local |