From da4df6c21d1d3c18ab88bc717169fbefa4cabc5b Mon Sep 17 00:00:00 2001 From: Erki Aas Date: Sat, 19 Oct 2024 13:51:13 +0300 Subject: [PATCH] frigate: move storage to dedicated nfs share and offload transcoding to separate go2rtc deployment --- frigate/application.yml | 37 ++++--------------- frigate/storage.yml | 32 +++++++++++++++++ frigate/transcode.yml | 80 +++++++++++++++++++++++++++++++++++++++++ frigate/values.yaml | 21 ++++------- 4 files changed, 124 insertions(+), 46 deletions(-) create mode 100644 frigate/storage.yml create mode 100644 frigate/transcode.yml diff --git a/frigate/application.yml b/frigate/application.yml index 739dd15..52098f3 100644 --- a/frigate/application.yml +++ b/frigate/application.yml @@ -49,18 +49,11 @@ data: default: 30 mode: motion - go2rtc: - streams: - server_room: "ffmpeg:http://user:{FRIGATE_RTSP_PASSWORD}@100.102.2.2:8080/?action=stream#video=h264" - chaos: "ffmpeg:http://user:{FRIGATE_RTSP_PASSWORD}@100.102.2.3:8080/?action=stream#video=h264" - cyber: "ffmpeg:http://user:{FRIGATE_RTSP_PASSWORD}@100.102.2.8:8080/?action=stream#video=h264" - workshop: "ffmpeg:http://user:{FRIGATE_RTSP_PASSWORD}@100.102.2.10:8080/?action=stream#video=h264" - cameras: server_room: ffmpeg: inputs: - - path: rtsp://127.0.0.1:8554/server_room + - path: rtsp://go2rtc:8554/server_room roles: - detect - rtmp @@ -68,7 +61,7 @@ data: chaos: ffmpeg: inputs: - - path: rtsp://127.0.0.1:8554/chaos + - path: rtsp://go2rtc:8554/chaos roles: - detect - rtmp @@ -76,7 +69,7 @@ data: cyber: ffmpeg: inputs: - - path: rtsp://127.0.0.1:8554/cyber + - path: rtsp://go2rtc:8554/cyber roles: - detect - rtmp @@ -84,7 +77,7 @@ data: workshop: ffmpeg: inputs: - - path: rtsp://127.0.0.1:8554/workshop + - path: rtsp://go2rtc:8554/workshop roles: - detect - rtmp @@ -108,24 +101,6 @@ spec: storage: "100Mi" storageClassName: "frigate-config" --- -# Source: frigate/templates/media-pvc.yaml -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: frigate-media - labels: - app.kubernetes.io/name: frigate - helm.sh/chart: frigate-7.6.0 - app.kubernetes.io/instance: frigate - app.kubernetes.io/managed-by: Helm -spec: - accessModes: - - "ReadWriteOnce" - resources: - requests: - storage: "100Gi" - storageClassName: "frigate-data" ---- # Source: frigate/templates/service.yaml apiVersion: v1 kind: Service @@ -190,7 +165,7 @@ spec: app.kubernetes.io/name: frigate app.kubernetes.io/instance: frigate annotations: - checksum/configmap: a133d33879aa679164f4757e66467236f5aa19733c6bbaf2ac3e53e56e9a758b + checksum/configmap: 9de9e29d499af45a0e7392032d64d26d8e13e12211971a307f201c97ac91f173 spec: containers: - name: frigate @@ -260,7 +235,7 @@ spec: emptyDir: {} - name: media persistentVolumeClaim: - claimName: frigate-media + claimName: frigate-storage - name: dshm emptyDir: medium: Memory diff --git a/frigate/storage.yml b/frigate/storage.yml new file mode 100644 index 0000000..a9f3c63 --- /dev/null +++ b/frigate/storage.yml @@ -0,0 +1,32 @@ +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: frigate-storage +spec: + persistentVolumeReclaimPolicy: Retain + capacity: + storage: 1Ti + accessModes: + - ReadWriteMany + storageClassName: "" + nfs: + server: 172.21.0.7 + path: /nas/k6/frigate + mountOptions: + - vers=4 + - minorversion=1 + - noac +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: frigate-storage +spec: + volumeName: frigate-storage + storageClassName: "" + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Ti diff --git a/frigate/transcode.yml b/frigate/transcode.yml new file mode 100644 index 0000000..4526802 --- /dev/null +++ b/frigate/transcode.yml @@ -0,0 +1,80 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: go2rtc + labels: + app.kubernetes.io/name: go2rtc + app.kubernetes.io/instance: go2rtc +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app.kubernetes.io/name: go2rtc + app.kubernetes.io/instance: go2rtc + template: + metadata: + labels: + app.kubernetes.io/name: go2rtc + app.kubernetes.io/instance: go2rtc + spec: + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - frigate + topologyKey: "kubernetes.io/hostname" + # nodeSelector: + # dedicated: nvr + # tolerations: + # - key: dedicated + # operator: Equal + # value: nvr + # effect: NoSchedule + containers: + - name: go2rtc + image: alexxit/go2rtc + ports: + - name: rtsp + containerPort: 8554 + protocol: TCP + - name: api + containerPort: 1984 + protocol: TCP + volumeMounts: + - mountPath: /config/go2rtc.yaml + subPath: config.yml + name: config + resources: + {} + volumes: + - name: config + secret: + secretName: go2rtc-config + items: + - key: config.yml + path: config.yml +--- +apiVersion: v1 +kind: Service +metadata: + name: go2rtc + labels: + app.kubernetes.io/name: go2rtc + app.kubernetes.io/instance: go2rtc +spec: + type: ClusterIP + ipFamilyPolicy: SingleStack + ports: + - name: rtsp + port: 8554 + protocol: TCP + targetPort: rtsp + selector: + app.kubernetes.io/name: go2rtc + app.kubernetes.io/instance: go2rtc \ No newline at end of file diff --git a/frigate/values.yaml b/frigate/values.yaml index 664b1e7..526f040 100644 --- a/frigate/values.yaml +++ b/frigate/values.yaml @@ -87,18 +87,11 @@ config: | default: 30 mode: motion - go2rtc: - streams: - server_room: "ffmpeg:http://user:{FRIGATE_RTSP_PASSWORD}@100.102.2.2:8080/?action=stream#video=h264" - chaos: "ffmpeg:http://user:{FRIGATE_RTSP_PASSWORD}@100.102.2.3:8080/?action=stream#video=h264" - cyber: "ffmpeg:http://user:{FRIGATE_RTSP_PASSWORD}@100.102.2.8:8080/?action=stream#video=h264" - workshop: "ffmpeg:http://user:{FRIGATE_RTSP_PASSWORD}@100.102.2.10:8080/?action=stream#video=h264" - cameras: server_room: ffmpeg: inputs: - - path: rtsp://127.0.0.1:8554/server_room + - path: rtsp://go2rtc:8554/server_room roles: - detect - rtmp @@ -106,7 +99,7 @@ config: | chaos: ffmpeg: inputs: - - path: rtsp://127.0.0.1:8554/chaos + - path: rtsp://go2rtc:8554/chaos roles: - detect - rtmp @@ -114,7 +107,7 @@ config: | cyber: ffmpeg: inputs: - - path: rtsp://127.0.0.1:8554/cyber + - path: rtsp://go2rtc:8554/cyber roles: - detect - rtmp @@ -122,7 +115,7 @@ config: | workshop: ffmpeg: inputs: - - path: rtsp://127.0.0.1:8554/workshop + - path: rtsp://go2rtc:8554/workshop roles: - detect - rtmp @@ -181,7 +174,5 @@ persistence: media: enabled: true - storageClass: "frigate-data" - accessMode: ReadWriteOnce - size: 100Gi - skipuninstall: false + existingClaim: "frigate-storage" + skipuninstall: true