local kube = import "k8s/configs/base.libsonnet"; local linuxserver = import "k8s/configs/templates/core/linuxserver.libsonnet"; local images = import "k8s/configs/images.libsonnet"; local probe(delaySeconds) = { initialDelaySeconds: delaySeconds, periodSeconds: 20, tcpSocket: { port: "http", }, }; local WebPort = 5000; local RtspPort = 8554; local Params = kube.simpleFieldStruct([ "namespace", "name", "filePath", "dbClaimName", "configClaimName", "storageClaimName", "mqttAddress", "rtspNodePort", //"ingressHost", "frigateRtspPwd", "frigateGarageSourceRtsp", ]) { local rtmpPort = 1935, labels: {}, gatekeeperSidecar: null, configMapName: $.name + "-config", lsParams: linuxserver.AppParams { name: $.name, namespace: $.namespace, filePath: $.filePath, templatePath: std.thisFile, baseAppName: "frigate", imageName: "blakeblackshear/frigate", labels+: $.labels, gatekeeperSidecar: $.gatekeeperSidecar, isPrivileged: true, services: [ linuxserver.Service { suffix: "ui", spec: { type: "ClusterIP", ports: [ kube.SvcUtil.TCPServicePort("http", 80) { targetPort: WebPort }, kube.SvcUtil.TCPServicePort("rtmp", rtmpPort) { targetPort: rtmpPort }, ], }, }, linuxserver.Service { suffix: "rtsp", spec: kube.SvcUtil.BasicNodePortSpec(RtspPort, $.rtspNodePort), }, ], nodeSelector: { "has_coral": "true" }, ports: [ kube.DeployUtil.ContainerPort("http", WebPort), kube.DeployUtil.ContainerPort("rtmp", rtmpPort), kube.DeployUtil.ContainerPort("rtsp", RtspPort), ], env: linuxserver.Env { others: [ kube.NameVal("FRIGATE_RTSP_PASSWORD", "acmcarther"), ] }, pvcs: [ linuxserver.Pvc{ name: "frigate-db", mountPath: "/db", bindName: $.dbClaimName, }, linuxserver.Pvc{ name: "frigate-config", mountPath: "/config", bindName: $.configClaimName, }, linuxserver.Pvc{ name: "frigate-storage", mountPath: "/media", bindName: $.storageClaimName, }, ], // This was removed 2024-10-05 /* configMaps: [ linuxserver.ConfigMap { name: "config", mountPath: "/config", bindName: $.configMapName, }, ], */ hostPaths: [ linuxserver.HostPath{ name: "usb", hostPath: "/dev/bus/usb", mountPath: "/dev/bus/usb", }, ], emptyDirs: [ linuxserver.EmptyDir { name: "dshm", mountPath: "/dev/shm", medium: "Memory", }, ], resources: { requests: { cpu: "400m", memory: "2028Mi", }, limits: { cpu: "1500m", memory: "4096Mi", }, }, livenessProbe: probe(/*delaySeconds=*/60), readinessProbe: probe(/*delaySeconds=*/60), }, }; local ConfigMap(params) = kube.ConfigMap(params.namespace, params.name + "-config") { data: { "config.yml": ||| database: path: "/db/frigate.db" mqtt: host: %(mqttAddress)s port: 80 detectors: coral: type: edgetpu device: usb objects: track: - person - bear - cat - mouse - dog ffmpeg: output_args: record: preset-record-generic-audio-aac go2rtc: rtsp: username: "acmcarther" password: "%(frigateRtspPwd)s" streams: garage_rtsp_cam_live: # subtype=0 is main stream with audio - "%(frigateGarageSourceRtsp)s&subtype=0" - "ffmpeg:garage_rtsp_cam_live#audio=opus" cameras: garage: live: stream_name: garage_rtsp_cam_live ffmpeg: # Configure output for restream output_args: record: preset-record-generic-audio-copy inputs: - path: rtsp://127.0.0.1:8554/garage_rtsp_cam_live input_args: preset-rtsp-restream roles: - record # subtype 1 is substream without audio - path: "%(frigateGarageSourceRtsp)s&subtype=1" roles: - restream # subtype 2 is substream for detection - path: "%(frigateGarageSourceRtsp)s&subtype=2" roles: - detect detect: width: 1280 height: 720 zones: street: coordinates: 1280,0,1280,316,1130,316,824,270,631,196,503,0 objects: - bear driveway: coordinates: 0,720,1280,720,1280,414,752,257,577,154,0,144 objects: - person - cat - bear - mouse record: enabled: True events: retain: default: 7 mode: active_objects snapshots: enabled: True timestamp: True ||| % { mqttAddress: params.mqttAddress, frigateRtspPwd: params.frigateRtspPwd, frigateGarageSourceRtsp: params.frigateGarageSourceRtsp, }, }, }; local App(params) = linuxserver.App(params.lsParams) { configMap: ConfigMap(params), }; { WebPort: WebPort, RtspPort: RtspPort, Params: Params, App(params): App(params), }