Skip to content

Commit

Permalink
feat: Added support for nats (#163)
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Morton <[email protected]>

Signed-off-by: Kyle Morton <[email protected]>
Co-authored-by: Kyle Morton <[email protected]>
  • Loading branch information
drkfmorton and Kyle Morton authored Dec 8, 2022
1 parent d1db7a9 commit ae28201
Show file tree
Hide file tree
Showing 34 changed files with 486 additions and 6 deletions.
10 changes: 10 additions & 0 deletions deployment/helm/templates/configmaps/as-common-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: as-common-variables
data:
DATABASE_HOST: edgex-redis
{{- if (eq .Values.edgex.features.messagebusbackend "redis") }}
TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST: edgex-redis
TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST: edgex-redis
{{- end}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: device-common-variables
data:
{{- if (eq .Values.edgex.features.messagebusbackend "redis") }}
MESSAGEQUEUE_HOST: edgex-redis
{{- end}}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ data:
CLIENTS_CORE_COMMAND_HOST: {{.Values.edgex.app.core.command}}
CLIENTS_SUPPORT_NOTIFICATIONS_HOST: {{.Values.edgex.app.support.notifications}}
CLIENTS_SUPPORT_SCHEDULER_HOST: {{.Values.edgex.app.support.scheduler}}
MESSAGEQUEUE_HOST: {{.Values.edgex.app.redis}}
REGISTRY_HOST: {{.Values.edgex.app.consul}}
DATABASES_PRIMARY_HOST: {{.Values.edgex.app.redis}}
{{- if (eq .Values.edgex.features.messagebusbackend "redis") }}
MESSAGEQUEUE_HOST: {{.Values.edgex.app.redis}}
{{- end}}
{{- if .Values.edgex.security.enabled }}
EDGEX_SECURITY_SECRET_STORE: "true"
SECRETSTORE_HOST: edgex-vault
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Copyright (C) 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
org.edgexfoundry.service: {{.Values.edgex.app.appservice.externalmqtttrigger}}
name: {{.Values.edgex.app.appservice.externalmqtttrigger}}
spec:
replicas: {{.Values.edgex.replicas.appservice.externalmqtttrigger}}
selector:
matchLabels:
org.edgexfoundry.service: {{.Values.edgex.app.appservice.externalmqtttrigger}}
strategy: {}
template:
metadata:
labels:
org.edgexfoundry.service: {{.Values.edgex.app.appservice.externalmqtttrigger}}
spec:
{{- if and (eq .Values.edgex.security.enabled true) (or (eq .Values.edgex.storage.sharedVolumesAccessMode "ReadWriteOnce") (eq .Values.edgex.storage.useHostPath true))}}
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
org.edgexfoundry.service: {{ .Values.edgex.app.secretstoresetup}}
topologyKey: "kubernetes.io/hostname"
{{- end}}
automountServiceAccountToken: false
containers:
- name: {{.Values.edgex.app.appservice.externalmqtttrigger}}
image: {{.Values.edgex.image.appservice.externalmqtttrigger.repository}}:{{.Values.edgex.image.appservice.externalmqtttrigger.tag}}
imagePullPolicy: {{.Values.edgex.image.appservice.externalmqtttrigger.pullPolicy}}
{{- if .Values.edgex.security.enabled }}
command: ["/edgex-init/ready_to_run_wait_install.sh"]
args: ["/app-service-configurable", "-cp=consul.http://edgex-core-consul:8500", "--registry", "--confdir=/res"]
{{- end}}
ports:
- containerPort: {{.Values.edgex.port.appservice.externalmqtttrigger}}
{{- if not .Values.edgex.security.enabled }}
hostPort: {{.Values.edgex.port.appservice.externalmqtttrigger}}
hostIP: {{.Values.edgex.hostPortInternalBind}}
{{- end}}
envFrom:
- configMapRef:
name: edgex-common-variables
env:
- name: EDGEX_PROFILE
value: "edgex-app-external-mqtt-trigger"
- name: SERVICE_HOST
value: {{.Values.edgex.app.appservice.externalmqtttrigger}}
- name: WRITABLE_LOGLEVEL
value: INFO
{{- if (eq .Values.edgex.features.messagebusbackend "redis") }}
- name: TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST
value: {{.Values.edgex.app.redis}}
- name: TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST
value: {{.Values.edgex.app.redis}}
{{- end}}
{{- if (eq .Values.edgex.features.messagebusbackend "mqtt") }}
- name: WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_BROKERADDRESS
value: "{{.Values.edgex.features.mqttBrokerAddress}}"
- name: WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_TOPIC
value: edgex-export
- name: TRIGGER_EXTERNALMQTT_URL
value: "{{.Values.edgex.features.mqttBrokerAddress}}"
{{- end}}


securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
startupProbe:
httpGet:
path: /api/v2/ping
port: {{.Values.edgex.port.appservice.externalmqtttrigger}}
periodSeconds: 1
failureThreshold: 120
livenessProbe:
httpGet:
path: /api/v2/ping
port: {{.Values.edgex.port.appservice.externalmqtttrigger}}
{{- if .Values.edgex.security.enabled }}
volumeMounts:
- mountPath: /edgex-init
name: edgex-init
- mountPath: /tmp/edgex/secrets
name: edgex-secrets
{{- end }}
{{- if .Values.edgex.resources.appservice.externalmqtttrigger.enforceLimits }}
resources:
limits:
memory: {{ .Values.edgex.resources.appservice.externalmqtttrigger.limits.memory }}
cpu: {{ .Values.edgex.resources.appservice.externalmqtttrigger.limits.cpu }}
requests:
memory: {{ .Values.edgex.resources.appservice.externalmqtttrigger.requests.memory }}
cpu: {{ .Values.edgex.resources.appservice.externalmqtttrigger.requests.cpu }}
{{- end}}
hostname: {{.Values.edgex.app.appservice.externalmqtttrigger}}
restartPolicy: Always
securityContext:
runAsNonRoot: true
runAsUser: {{ .Values.edgex.security.runAsUser }}
runAsGroup: {{ .Values.edgex.security.runAsGroup }}
{{- if .Values.edgex.security.enabled }}
volumes:
- name: edgex-init
persistentVolumeClaim:
claimName: edgex-init
- name: edgex-secrets
persistentVolumeClaim:
claimName: edgex-secrets
{{- end}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
apiVersion: v1
kind: Service
metadata:
labels:
org.edgexfoundry.service: {{.Values.edgex.app.appservice.externalmqtttrigger}}
name: {{.Values.edgex.app.appservice.externalmqtttrigger}}
spec:
ports:
- name: "http"
port: {{.Values.edgex.port.appservice.externalmqtttrigger}}
selector:
org.edgexfoundry.service: {{.Values.edgex.app.appservice.externalmqtttrigger}}
type: {{.Values.expose.type}}
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,23 @@ spec:
value: "http-export"
- name: SERVICE_HOST
value: {{.Values.edgex.app.appservice.httpexport}}
{{- if (eq .Values.edgex.features.messagebusbackend "redis") }}
- name: TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST
value: {{.Values.edgex.app.redis}}
- name: TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST
value: {{.Values.edgex.app.redis}}
{{- end}}
{{- if (eq .Values.edgex.features.messagebusbackend "nats") }}
- name: WRITABLE_PIPELINE_FUNCTIONS_HTTPEXPORT_PARAMETERS_URL
value: "{{.Values.edgex.features.httpExportURL}}"
- name: WRITABLE_LOGLEVEL
value: INFO
{{- end}}
envFrom:
- configMapRef:
name: edgex-common-variables
- configMapRef:
name: as-common-variables
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ spec:
envFrom:
- configMapRef:
name: edgex-common-variables
- configMapRef:
name: as-common-variables
env:
- name: EDGEX_PROFILE
value: "metrics-influxdb"
- name: SERVICE_HOST
value: {{.Values.edgex.app.appservice.metricsinfluxdb}}
{{- if (eq .Values.edgex.features.messagebusbackend "redis") }}
- name: TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST
value: {{.Values.edgex.app.redis}}
- name: TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST
value: {{.Values.edgex.app.redis}}
{{end}}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,31 @@ spec:
envFrom:
- configMapRef:
name: edgex-common-variables
- configMapRef:
name: as-common-variables
env:
- name: EDGEX_PROFILE
value: "mqtt-export"
- name: SERVICE_HOST
value: {{.Values.edgex.app.appservice.mqttexport}}
- name: WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_BROKERADDRESS
value: "{{.Values.edgex.features.mqttBrokerAddress}}"
- name: WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_TOPIC
value: edgex-events
- name: WRITABLE_LOGLEVEL
value: INFO
{{- if (eq .Values.edgex.features.messagebusbackend "redis") }}
- name: TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST
value: {{.Values.edgex.app.redis}}
- name: TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST
- name: WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_BROKERADDRESS
value: {{.Values.edgex.app.redis}}
{{- end}}
{{- if (eq .Values.edgex.features.messagebusbackend "nats") }}
- name: TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST
value: "{{.Values.edgex.features.mqttBrokerAddress}}"
- name: WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_TOPIC
value: edgex-events
{{- end}}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ spec:
envFrom:
- configMapRef:
name: edgex-common-variables
- configMapRef:
name: as-common-variables
env:
- name: SERVICE_HOST
value: {{.Values.edgex.app.appservice.rfidllrpinventory}}
{{- if (eq .Values.edgex.features.messagebusbackend "redis") }}
- name: TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST
value: {{.Values.edgex.app.redis}}
- name: TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST
value: {{.Values.edgex.app.redis}}
{{end}}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ spec:
envFrom:
- configMapRef:
name: edgex-common-variables
- configMapRef:
name: as-common-variables
env:
- name: EDGEX_PROFILE
value: "sample"
- name: SERVICE_HOST
value: {{.Values.edgex.app.appservice.appsample}}
{{- if (eq .Values.edgex.features.messagebusbackend "redis") }}
- name: TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST
value: {{.Values.edgex.app.redis}}
- name: TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST
value: {{.Values.edgex.app.redis}}
{{end}}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,33 @@ spec:
value: "rules-engine"
- name: SERVICE_HOST
value: {{.Values.edgex.app.appservice.rules}}
{{- if (eq .Values.edgex.features.messagebusbackend "redis") }}
- name: TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST
value: {{.Values.edgex.app.redis}}
- name: TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST
value: {{.Values.edgex.app.redis}}
{{- end}}
{{- if (eq .Values.edgex.features.messagebusbackend "nats") }}
- name: TRIGGER_EDGEXMESSAGEBUS_OPTIONAL_AUTHMODE
value: none
- name: TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST
value: edgex-nats-server
- name: TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_PORT
value: "4222"
- name: TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_PROTOCOL
value: tcp
- name: TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_PUBLISHTOPIC
value: edgex/rules-events
- name: TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST
value: edgex-nats-server
- name: TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_PORT
value: "4222"
- name: TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_PROTOCOL
value: tcp
- name: TRIGGER_EDGEXMESSAGEBUS_TYPE
value: nats-jetstream
{{- end}}

securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ spec:
env:
- name: SERVICE_HOST
value: {{.Values.edgex.app.core.command}}
{{- if (eq .Values.edgex.features.messagebusbackend "nats") }}
- name: MESSAGEQUEUE_INTERNAL_AUTHMODE
value: none
- name: MESSAGEQUEUE_INTERNAL_HOST
value: edgex-nats-server
- name: MESSAGEQUEUE_INTERNAL_PORT
value: "4222"
- name: MESSAGEQUEUE_INTERNAL_PROTOCOL
value: tcp
- name: MESSAGEQUEUE_INTERNAL_TYPE
value: nats-jetstream
{{end}}
envFrom:
- configMapRef:
name: edgex-common-variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ spec:
- name: SECRETSTORE_TOKENFILE
value: /tmp/edgex/secrets/core-data/secrets-token.json
{{- end}}
{{- if (eq .Values.edgex.features.messagebusbackend "nats") }}
- name: MESSAGEQUEUE_AUTHMODE
value: none
- name: MESSAGEQUEUE_HOST
value: edgex-nats-server
- name: MESSAGEQUEUE_OPTIONAL_CLIENTID
value: core-data
- name: MESSAGEQUEUE_PORT
value: '4222'
- name: MESSAGEQUEUE_PROTOCOL
value: tcp
- name: MESSAGEQUEUE_TYPE
value: nats-jetstream
{{end}}
envFrom:
- configMapRef:
name: edgex-common-variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ spec:
envFrom:
- configMapRef:
name: edgex-common-variables
- configMapRef:
name: device-common-variables
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ spec:
envFrom:
- configMapRef:
name: edgex-common-variables
- configMapRef:
name: device-common-variables
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ spec:
envFrom:
- configMapRef:
name: edgex-common-variables
- configMapRef:
name: device-common-variables
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ spec:
envFrom:
- configMapRef:
name: edgex-common-variables
- configMapRef:
name: device-common-variables
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down
Loading

0 comments on commit ae28201

Please sign in to comment.