NAS-123485 / 24.04 / Add frigate to community apps (#1434)

* Add `frigate` to `community` apps

* add cia values

* add initial templtes

* add values

* add common

* fix typo

* another one

* make it non-fail no matter the indendation

* typo

* questions and gpu

* perms

* more caps

* port

* shm and usb

* whops

* privieleged on usb bus mount

* invert logic
This commit is contained in:
Stavros Kois
2023-08-11 18:23:30 +03:00
committed by GitHub
parent ea0613dc29
commit 310d6d6426
20 changed files with 812 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: file://../../../common
version: 1.0.12
digest: sha256:debd30721d09ae8293b1cbdd9d0115981d40b47908be3035fc3cf657c9d5eedb
generated: "2023-08-09T18:48:28.063805611+03:00"

View File

@@ -0,0 +1,25 @@
name: frigate
description: Frigate is an NVR With Realtime Object Detection for IP Cameras
annotations:
title: Frigate
type: application
version: 1.0.0
apiVersion: v2
appVersion: 0.12.1
kubeVersion: '>=1.16.0-0'
maintainers:
- name: truenas
url: https://www.truenas.com/
email: dev@ixsystems.com
dependencies:
- name: common
repository: file://../../../common
version: 1.0.12
home: https://github.com/blakeblackshear/frigate
icon: https://raw.githubusercontent.com/blakeblackshear/frigate/dev/web/images/favicon.svg
sources:
- https://github.com/truenas/charts/tree/master/library/ix-dev/community/frigate
- https://github.com/blakeblackshear/frigate
keywords:
- camera
- nvr

View File

@@ -0,0 +1,5 @@
# Frigate
[Frigate](https://github.com/frigate/frigate) is an NVR With Realtime Object Detection for IP Cameras
> Note: **m.2** Coral TPU devices is not supported.

View File

@@ -0,0 +1,5 @@
# Frigate
[Frigate](https://github.com/frigate/frigate) is an NVR With Realtime Object Detection for IP Cameras
> Note: **m.2** Coral TPU devices is not supported.

View File

@@ -0,0 +1,20 @@
frigateNetwork:
webPort: 31000
enableRtmp: true
rtmpPort: 31001
enableRtsp: true
rtspPort: 31002
enableWebRtc: true
webRtcPort: 31003
frigateStorage:
config:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/config
media:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/media
cache:
sizeGiB: 2
shm:
sizeMiB: 128

View File

@@ -0,0 +1,30 @@
frigateNetwork:
webPort: 31000
enableRtmp: true
rtmpPort: 31001
enableRtsp: true
rtspPort: 31002
enableWebRtc: true
webRtcPort: 31003
frigateConfig:
mountUSBBus: true
frigateStorage:
config:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/config
media:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/media
cache:
sizeGiB: 2
shm:
sizeMiB: 128
additionalStorages:
- type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/clips
mountPath: /clips
- type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/snapshots
mountPath: /snapshots

View File

@@ -0,0 +1,17 @@
frigateNetwork:
enableRtmp: true
enableRtsp: true
enableWebRtc: true
hostNetwork: true
frigateStorage:
config:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/config
media:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/media
cache:
sizeGiB: 2
shm:
sizeMiB: 128

View File

@@ -0,0 +1,10 @@
icon_url: https://raw.githubusercontent.com/blakeblackshear/frigate/dev/web/images/favicon.svg
categories:
- security
screenshots:
- https://github.com/blakeblackshear/frigate/raw/dev/docs/static/img/media_browser.png
- https://github.com/blakeblackshear/frigate/raw/dev/docs/static/img/camera-ui.png
- https://github.com/blakeblackshear/frigate/raw/dev/docs/static/img/events-ui.png
tags:
- camera
- nvr

View File

@@ -0,0 +1,18 @@
runAsContext:
- userName: root
groupName: root
gid: 0
uid: 0
description: Frigate runs as root user. When USB Bus is mounted, it is able to escalate privileges.
capabilities:
- name: CHOWN
description: Frigate is able to chown files.
- name: FOWNER
description: Frigate are able to bypass permission checks for it's sub-processes.
- name: DAC_OVERRIDE
description: Frigate is able to bypass permission checks.
- name: SETGID
description: Frigate is able to set group ID for it's sub-processes.
- name: SETUID
description: Frigate is able to set user ID for it's sub-processes.
hostMounts: []

View File

@@ -0,0 +1,351 @@
groups:
- name: Frigate Configuration
description: Configure Frigate
- name: Network Configuration
description: Configure Network for Frigate
- name: Storage Configuration
description: Configure Storage for Frigate
- name: Resources Configuration
description: Configure Resources for Frigate
portals:
web_portal:
protocols:
- "$kubernetes-resource_configmap_portal_protocol"
host:
- "$kubernetes-resource_configmap_portal_host"
ports:
- "$kubernetes-resource_configmap_portal_port"
path: "$kubernetes-resource_configmap_portal_path"
questions:
- variable: frigateConfig
label: ""
group: Frigate Configuration
schema:
type: dict
attrs:
- variable: mountUSBBus
label: Mount USB Bus
description: |
Mount the USB bus to the container.</br>
This is required if you want to use USB devices, like Coral</br>
This will mount the USB bus to /dev/bus/usb inside the container.
schema:
type: boolean
default: false
- variable: additionalEnvs
label: Additional Environment Variables
description: Configure additional environment variables for Frigate.
schema:
type: list
default: []
items:
- variable: env
label: Environment Variable
schema:
type: dict
attrs:
- variable: name
label: Name
schema:
type: string
required: true
- variable: value
label: Value
schema:
type: string
required: true
- variable: frigateNetwork
label: ""
group: Network Configuration
schema:
type: dict
attrs:
- variable: hostNetwork
label: Host Network
description: |
Bind to the host network. It's recommended to keep this disabled.</br>
schema:
type: boolean
default: false
show_subquestions_if: false
subquestions:
- variable: webPort
label: Web Port
description: |
The port for the Frigate Web UI.</br>
Internal port: 5000
schema:
type: int
default: 30058
min: 9000
max: 65535
required: true
- variable: enableRtmp
label: Enable RTMP
description: Enable RTMP for Frigate.
schema:
type: boolean
default: false
- variable: rtmpPort
label: RTMP Port
description: |
The RTMP port for Frigate.</br>
Internal port: 1935
schema:
type: int
default: 30059
show_if: [["enableRtmp", "=", true]]
min: 9000
max: 65535
required: true
- variable: enableRtsp
label: Enable RTSP
description: Enable RTSP for Frigate.
schema:
type: boolean
default: false
- variable: rtspPort
label: RTSP Port
description: |
The RTSP port for Frigate.</br>
Internal port: 8554
schema:
type: int
default: 30060
show_if: [["enableRtsp", "=", true]]
min: 9000
max: 65535
required: true
- variable: enableWebRtc
label: Enable WebRTC
description: Enable WebRTC for Frigate.
schema:
type: boolean
default: false
- variable: webRtcPort
label: WebRTC Port
description: |
The WebRTC port for Frigate.</br>
Internal port: 8555</br>
Applies to both TCP and UDP.
schema:
type: int
default: 30061
show_if: [["enableWebRtc", "=", true]]
min: 9000
max: 65535
required: true
- variable: frigateStorage
label: ""
group: Storage Configuration
schema:
type: dict
attrs:
- variable: config
label: Frigate Config Storage
description: The path to store Frigate Configuration.
schema:
type: dict
attrs:
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.
schema:
type: string
required: true
default: "ixVolume"
enum:
- value: "hostPath"
description: Host Path (Path that already exists on the system)
- value: "ixVolume"
description: ixVolume (Dataset created automatically by the system)
- variable: datasetName
label: Dataset Name
schema:
type: string
show_if: [["type", "=", "ixVolume"]]
required: true
hidden: true
immutable: true
default: "config"
$ref:
- "normalize/ixVolume"
- variable: hostPath
label: Host Path
schema:
type: hostpath
show_if: [["type", "=", "hostPath"]]
immutable: true
required: true
- variable: media
label: Frigate Media Storage
description: The path to store Frigate Media.
schema:
type: dict
attrs:
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.
schema:
type: string
required: true
default: "ixVolume"
enum:
- value: "hostPath"
description: Host Path (Path that already exists on the system)
- value: "ixVolume"
description: ixVolume (Dataset created automatically by the system)
- variable: datasetName
label: Dataset Name
schema:
type: string
show_if: [["type", "=", "ixVolume"]]
required: true
hidden: true
immutable: true
default: "config"
$ref:
- "normalize/ixVolume"
- variable: hostPath
label: Host Path
schema:
type: hostpath
show_if: [["type", "=", "hostPath"]]
immutable: true
required: true
- variable: cache
label: Frigate Cache Storage
schema:
type: dict
attrs:
- variable: sizeGiB
label: Size (GiB)
description: The size of RAM is allowed to Frigate to use as cache
schema:
type: int
max: 4
default: 1
required: true
- variable: shm
label: Frigate /dev/shm Storage
schema:
type: dict
attrs:
- variable: sizeMiB
label: Size (MiB)
description: |
The size of RAM is allowed to Frigate to use as /dev/shm</br>
https://docs.frigate.video/frigate/installation/#calculating-required-shm-size
schema:
type: int
max: 2048
default: 64
required: true
- variable: additionalStorages
label: Additional Storage
description: Additional storage for Frigate.
schema:
type: list
default: []
items:
- variable: storageEntry
label: Storage Entry
schema:
type: dict
attrs:
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.
schema:
type: string
required: true
default: "ixVolume"
enum:
- value: "hostPath"
description: Host Path (Path that already exists on the system)
- value: "ixVolume"
description: ixVolume (Dataset created automatically by the system)
- variable: mountPath
label: Mount Path
description: The path inside the container to mount the storage.
schema:
type: path
required: true
- variable: hostPath
label: Host Path
description: The host path to use for storage.
schema:
type: hostpath
show_if: [["type", "=", "hostPath"]]
required: true
- variable: datasetName
label: Dataset Name
description: The name of the dataset to use for storage.
schema:
type: string
show_if: [["type", "=", "ixVolume"]]
required: true
immutable: true
default: "storage_entry"
$ref:
- "normalize/ixVolume"
- variable: resources
group: Resources Configuration
label: ""
schema:
type: dict
attrs:
- variable: limits
label: Limits
schema:
type: dict
attrs:
- variable: cpu
label: CPU
description: CPU limit for Frigate.
schema:
type: string
max_length: 6
valid_chars: '^(0\.[1-9]|[1-9][0-9]*)(\.[0-9]|m?)$'
valid_chars_error: |
Valid CPU limit formats are</br>
- Plain Integer - eg. 1</br>
- Float - eg. 0.5</br>
- Milicpu - eg. 500m
default: "4000m"
required: true
- variable: memory
label: Memory
description: Memory limit for Frigate.
schema:
type: string
max_length: 12
valid_chars: '^[1-9][0-9]*([EPTGMK]i?|e[0-9]+)?$'
valid_chars_error: |
Valid Memory limit formats are</br>
- Suffixed with E/P/T/G/M/K - eg. 1G</br>
- Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi</br>
- Plain Integer in bytes - eg. 1024</br>
- Exponent - eg. 134e6
default: "8Gi"
required: true
- variable: frigateGPU
group: Resources Configuration
label: GPU Configuration
schema:
type: dict
$ref:
- "definitions/gpuConfiguration"
attrs: []

View File

@@ -0,0 +1 @@
{{ include "ix.v1.common.lib.chart.notes" $ }}

View File

@@ -0,0 +1,92 @@
{{- define "frigate.workload" -}}
workload:
frigate:
enabled: true
primary: true
type: Deployment
podSpec:
hostNetwork: {{ .Values.frigateNetwork.hostNetwork }}
containers:
frigate:
enabled: true
primary: true
imageSelector: image
securityContext:
runAsUser: 0
runAsGroup: 0
runAsNonRoot: false
readOnlyRootFilesystem: false
{{- if .Values.frigateConfig.mountUSBBus }}
privileged: true
allowPrivilegeEscalation: true
{{- end }}
capabilities:
add:
- CHOWN
- DAC_OVERRIDE
- FOWNER
- SETUID
- SETGID
{{ with .Values.frigateConfig.additionalEnvs }}
envList:
{{ range $env := . }}
- name: {{ $env.name }}
value: {{ $env.value }}
{{ end }}
{{ end }}
probes:
liveness:
enabled: true
type: http
port: 5000
path: /api
readiness:
enabled: true
type: http
port: 5000
path: /api
startup:
enabled: true
type: http
port: 5000
path: /api
initContainers:
01-init:
enabled: true
type: init
imageSelector: bashImage
securityContext:
runAsUser: 0
runAsGroup: 0
runAsNonRoot: false
readOnlyRootFilesystem: false
command:
- /bin/sh
args:
- -c
- |
if [ ! -f /config/config.yml ]; then
{
echo 'mqtt:'
echo ' enabled: false'
echo 'cameras:'
echo ' dummy:'
echo ' enabled: false'
echo ' ffmpeg:'
echo ' inputs:'
echo ' - path: rtsp://127.0.0.1:554/rtsp'
echo ' roles:'
echo ' - detect'
} > /config/config.yml
fi
{{- with .Values.frigateGPU }}
scaleGPU:
{{- range $key, $value := . }}
- gpu:
{{ $key }}: {{ $value }}
targetSelector:
frigate:
- frigate
{{- end }}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,69 @@
{{- define "frigate.persistence" -}}
persistence:
config:
enabled: true
type: {{ .Values.frigateStorage.config.type }}
datasetName: {{ .Values.frigateStorage.config.datasetName | default "" }}
hostPath: {{ .Values.frigateStorage.config.hostPath | default "" }}
targetSelector:
frigate:
frigate:
mountPath: /config
01-init:
mountPath: /config
media:
enabled: true
type: {{ .Values.frigateStorage.media.type }}
datasetName: {{ .Values.frigateStorage.media.datasetName | default "" }}
hostPath: {{ .Values.frigateStorage.media.hostPath | default "" }}
targetSelector:
frigate:
frigate:
mountPath: /media
tmp:
enabled: true
type: emptyDir
targetSelector:
frigate:
frigate:
mountPath: /tmp
cache:
enabled: true
type: emptyDir
medium: Memory
size: {{ printf "%vGi" .Values.frigateStorage.cache.sizeGiB }}
targetSelector:
frigate:
frigate:
mountPath: /tmp/cache
shm:
enabled: true
type: emptyDir
medium: Memory
size: {{ printf "%vMi" .Values.frigateStorage.shm.sizeMiB }}
targetSelector:
frigate:
frigate:
mountPath: /dev/shm
{{- if .Values.frigateConfig.mountUSBBus }}
usb-bus:
enabled: true
type: hostPath
hostPath: /dev/bus/usb
targetSelector:
frigate:
frigate:
mountPath: /dev/bus/usb
{{- end -}}
{{- range $idx, $storage := .Values.frigateStorage.additionalStorages }}
{{ printf "frigate-%v" (int $idx) }}:
enabled: true
type: {{ $storage.type }}
datasetName: {{ $storage.datasetName | default "" }}
hostPath: {{ $storage.hostPath | default "" }}
targetSelector:
frigate:
frigate:
mountPath: {{ $storage.mountPath }}
{{- end }}
{{- end -}}

View File

@@ -0,0 +1,16 @@
{{- define "frigate.portal" -}}
{{- $port := .Values.frigateNetwork.webPort -}}
{{- if .Values.frigateNetwork.hostNetwork -}}
{{- $port = 5000 -}}
{{- end }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: portal
data:
path: "/"
port: {{ $port | quote }}
protocol: http
host: $node_ip
{{- end -}}

View File

@@ -0,0 +1,65 @@
{{- define "frigate.service" -}}
service:
frigate:
enabled: true
primary: true
type: NodePort
targetSelector: frigate
ports:
webui:
enabled: true
primary: true
port: {{ .Values.frigateNetwork.webPort }}
nodePort: {{ .Values.frigateNetwork.webPort }}
targetPort: 5000
targetSelector: frigate
{{ if .Values.frigateNetwork.enableRtmp }}
rtmp:
enabled: true
type: NodePort
targetSelector: frigate
ports:
rtmp:
enabled: true
primary: true
port: {{ .Values.frigateNetwork.rtmpPort }}
nodePort: {{ .Values.frigateNetwork.rtmpPort }}
targetPort: 1935
targetSelector: frigate
{{ end }}
{{ if .Values.frigateNetwork.enableRtsp }}
rtsp:
enabled: true
type: NodePort
targetSelector: frigate
ports:
rtsp:
enabled: true
primary: true
port: {{ .Values.frigateNetwork.rtspPort }}
nodePort: {{ .Values.frigateNetwork.rtspPort }}
targetPort: 8554
targetSelector: frigate
{{ end }}
{{ if .Values.frigateNetwork.enableWebRtc }}
webrtc:
enabled: true
type: NodePort
targetSelector: frigate
ports:
tcp:
enabled: true
primary: true
port: {{ .Values.frigateNetwork.webRtcPort }}
nodePort: {{ .Values.frigateNetwork.webRtcPort }}
targetPort: 8555
targetSelector: frigate
udp:
enabled: true
port: {{ .Values.frigateNetwork.webRtcPort }}
nodePort: {{ .Values.frigateNetwork.webRtcPort }}
targetPort: 8555
protocol: udp
targetSelector: frigate
{{ end }}
{{- end -}}

View File

@@ -0,0 +1,11 @@
{{- include "ix.v1.common.loader.init" . -}}
{{/* Merge the templates with Values */}}
{{- $_ := mustMergeOverwrite .Values (include "frigate.workload" $ | fromYaml) -}}
{{- $_ := mustMergeOverwrite .Values (include "frigate.service" $ | fromYaml) -}}
{{- $_ := mustMergeOverwrite .Values (include "frigate.persistence" $ | fromYaml) -}}
{{/* Create the configmap for portal manually*/}}
{{- include "frigate.portal" $ -}}
{{- include "ix.v1.common.loader.apply" . -}}

View File

@@ -0,0 +1 @@
{"filename": "values.yaml", "keys": ["image"]}

View File

@@ -0,0 +1,31 @@
#!/usr/bin/python3
import json
import re
import sys
from catalog_update.upgrade_strategy import semantic_versioning
RE_STABLE_VERSION = re.compile(r'\d+\.\d+\.\d+')
def newer_mapping(image_tags):
key = list(image_tags.keys())[0]
tags = {t: t for t in image_tags[key] if RE_STABLE_VERSION.fullmatch(t)}
version = semantic_versioning(list(tags))
if not version:
return {}
return {
'tags': {key: tags[version]},
'app_version': version,
}
if __name__ == '__main__':
try:
versions_json = json.loads(sys.stdin.read())
except ValueError:
raise ValueError('Invalid json specified')
print(json.dumps(newer_mapping(versions_json)))

View File

@@ -0,0 +1,39 @@
image:
repository: ghcr.io/blakeblackshear/frigate
pullPolicy: IfNotPresent
tag: 0.12.1
resources:
limits:
cpu: 4000m
memory: 8Gi
frigateConfig:
mountUSBBus: false
additionalEnvs: []
frigateNetwork:
hostNetwork: false
# Port numbers ignored if hostNetwork is true
webPort: 30058
enableRtmp: false
rtmpPort: 30059
enableRtsp: false
rtspPort: 30060
enableWebRtc: false
webRtcPort: 30061
frigateGPU: {}
frigateStorage:
media:
type: ixVolume
datasetName: media
config:
type: ixVolume
datasetName: config
cache:
sizeGiB: 1
shm:
sizeMiB: 64
additionalStorages: []