From da2489a4cc404b9f5c8b1cfba3c6e2c3f80e3e83 Mon Sep 17 00:00:00 2001 From: Ariel Sosnovsky Date: Thu, 19 Oct 2023 17:06:30 -0400 Subject: [PATCH] ser2sock --- k8s/apps/z2m/templates/config.yaml | 2 +- k8s/apps/z2m/templates/deployment.yaml | 3 ++ k8s/apps/z2m/templates/ser2sock.yaml | 71 ++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 k8s/apps/z2m/templates/ser2sock.yaml diff --git a/k8s/apps/z2m/templates/config.yaml b/k8s/apps/z2m/templates/config.yaml index 050164d..b0b90fa 100644 --- a/k8s/apps/z2m/templates/config.yaml +++ b/k8s/apps/z2m/templates/config.yaml @@ -15,7 +15,7 @@ data: user: "{{.Values.global.mqtt.username}}" password: "{{.Values.global.mqtt.password}}" serial: - port: "{{ .Values.devicePath }}" + port: "tcp://ser2sock.{{ .Release.Namespace }}.svc.cluster.local:10000" frontend: port: "8080" advanced: diff --git a/k8s/apps/z2m/templates/deployment.yaml b/k8s/apps/z2m/templates/deployment.yaml index 90b738f..9d12320 100644 --- a/k8s/apps/z2m/templates/deployment.yaml +++ b/k8s/apps/z2m/templates/deployment.yaml @@ -75,6 +75,9 @@ spec: - name: configuration mountPath: /app/configuration.yaml subPath: configuration.yaml + - name: configuration + mountPath: /config/configuration.yaml + subPath: configuration.yaml - name: udev mountPath: /run/udev diff --git a/k8s/apps/z2m/templates/ser2sock.yaml b/k8s/apps/z2m/templates/ser2sock.yaml new file mode 100644 index 0000000..a3c9599 --- /dev/null +++ b/k8s/apps/z2m/templates/ser2sock.yaml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: "ser2sock" +spec: + replicas: 1 + revisionHistoryLimit: 2 + strategy: + type: Recreate + selector: + matchLabels: + {{ .Release.Name }}/app: ser2sock + template: + metadata: + labels: + {{ .Release.Name }}/app: ser2sock + spec: + affinity: + {{- .Values.affinity | toYaml | nindent 12}} + containers: + - name: ser2sock + image: lansible/ser2sock:latest + imagePullPolicy: IfNotPresent + securityContext: + privileged: true + readOnlyRootFilesystem: true + ports: + - containerPort: 10000 + name: zigbee + volumeMounts: + - name: ser2sock-config + mountPath: /config + - name: zigbee-usb + mountPath: /dev/ttyACM0 + volumes: + - name: ser2sock-config + configMap: + name: ser2sock-config + - name: zigbee-usb + hostPath: + path: "{{ .Values.devicePath }}" + type: CharDevice +--- + apiVersion: v1 + kind: ConfigMap + metadata: + name: ser2sock-config + labels: + app: ser2sock + data: + ser2sock.conf: | + [ser2sock] + device = /dev/ttyACM0 + baudrate = 115200 + port = 10000 +--- +apiVersion: v1 +kind: Service +metadata: + name: ser2sock + labels: + {{ .Release.Name }}/app: ser2sock +spec: + type: ClusterIP + selector: + {{ .Release.Name }}/app: ser2sock + ports: + - port: 10000 + targetPort: 10000 + name: zigbee + protocol: TCP \ No newline at end of file