diff --git a/apps/argocd/base/home/frigate.yaml b/apps/argocd/base/home/frigate.yaml new file mode 100644 index 000000000..5a7d23ad2 --- /dev/null +++ b/apps/argocd/base/home/frigate.yaml @@ -0,0 +1,41 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: frigate + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: apps + source: + repoURL: "https://github.com/gruberdev/homelab.git" + path: apps/home/frigate + targetRevision: main + kustomize: + commonLabels: + app.kubernetes.io/category: home + destination: + namespace: homeassistant + name: in-cluster + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - Prune=true + - ServerSideApply=true + retry: + limit: 10 + backoff: + duration: 20s + factor: 2 + maxDuration: 15m + info: + - name: "Github Repository:" + value: >- + https://github.com/blakeblackshear/frigate + - name: "Official documentation:" + value: >- + https://docs.frigate.video/ + - name: "Homelab documentation:" + value: >- + https://github.com/gruberdev/homelab/tree/main/apps/home/frigate diff --git a/apps/argocd/base/home/kustomization.yaml b/apps/argocd/base/home/kustomization.yaml index 6f92e10e8..b2dfd9c71 100644 --- a/apps/argocd/base/home/kustomization.yaml +++ b/apps/argocd/base/home/kustomization.yaml @@ -5,6 +5,7 @@ resources: - openwakeword.yaml - piper.yaml - whisper.yaml + - frigate.yaml - wyze.yaml - external-mic.yaml - satellite.yaml diff --git a/apps/data/storage/base/home/frigate.yaml b/apps/data/storage/base/home/frigate.yaml new file mode 100644 index 000000000..0ed588f43 --- /dev/null +++ b/apps/data/storage/base/home/frigate.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: frigate-data + namespace: homeassistant +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 15Gi + storageClassName: mayastor-single-replica +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: frigate-media + namespace: homeassistant +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 80Gi + storageClassName: mayastor-single-replica diff --git a/apps/data/storage/base/home/kustomization.yaml b/apps/data/storage/base/home/kustomization.yaml index 173a81400..69a386580 100644 --- a/apps/data/storage/base/home/kustomization.yaml +++ b/apps/data/storage/base/home/kustomization.yaml @@ -6,6 +6,7 @@ resources: - piper.yaml - whisper.yaml - wyze.yaml + - frigate.yaml commonAnnotations: argocd.argoproj.io/sync-options: Delete=false diff --git a/apps/home/frigate/README.md b/apps/home/frigate/README.md new file mode 100644 index 000000000..a541ac089 --- /dev/null +++ b/apps/home/frigate/README.md @@ -0,0 +1 @@ +## Frigate NVR diff --git a/apps/home/frigate/base/cm.yaml b/apps/home/frigate/base/cm.yaml new file mode 100644 index 000000000..0704a722c --- /dev/null +++ b/apps/home/frigate/base/cm.yaml @@ -0,0 +1,39 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: frigate-config +data: + config.yml: | + go2rtc: + streams: + hall_cam: "ffmpeg:http://home-assistant.homeassistant.svc.cluster.local:8123/api/camera_proxy_stream/camera.acessoweb_scseg_com_br#video=h264#hardware#header='Authorization: Bearer {FRIGATE_HA_TOKEN}'#header='Content-Type: application/json'" + cameras: + hall_cam: + ffmpeg: + input_args: preset-rtsp-generic + inputs: + - path: rtsp://127.0.0.1:8554/hall_cam + roles: + - detect + - record + mqtt: + enabled: False + ffmpeg: + hwaccel_args: preset-nvidia-h264 + detectors: + tensorrt: + type: tensorrt + device: 0 + database: + path: /config/frigate.db + audio: + enabled: False + record: + enabled: True + retain: + days: 3 + mode: all + events: + retain: + default: 30 + mode: motion diff --git a/apps/home/frigate/base/deployment.yaml b/apps/home/frigate/base/deployment.yaml new file mode 100644 index 000000000..1f922a4c6 --- /dev/null +++ b/apps/home/frigate/base/deployment.yaml @@ -0,0 +1,97 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: frigate + labels: + app: frigate +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: frigate + template: + metadata: + labels: + app: frigate + spec: + runtimeClassName: nvidia + containers: + - name: frigate + image: ghcr.io/blakeblackshear/frigate:master-77e7777-tensorrt + imagePullPolicy: Always + env: + - name: NVIDIA_VISIBLE_DEVICES + value: "all" + - name: NVIDIA_DRIVER_CAPABILITIES + value: "all" + envFrom: + - secretRef: + name: frigate-vars + optional: true + livenessProbe: + httpGet: + path: / + port: web + scheme: HTTP + initialDelaySeconds: 30 + failureThreshold: 5 + timeoutSeconds: 10 + readinessProbe: + httpGet: + path: / + port: web + scheme: HTTP + initialDelaySeconds: 15 + failureThreshold: 5 + timeoutSeconds: 10 + ports: + - name: web + containerPort: 5000 + protocol: TCP + - name: rtsp + containerPort: 8554 + protocol: TCP + - name: webrtc-tcp + containerPort: 8555 + protocol: TCP + - name: webrtc-udp + containerPort: 8555 + protocol: UDP + resources: + requests: + cpu: 300m + memory: 512Mi + limits: + cpu: 800m + memory: 2Gi + volumeMounts: + - name: data + mountPath: /config + - name: configmap + mountPath: /config/config.yml + subPath: config.yml + - name: media + mountPath: /data + - name: cache + mountPath: /tmp/cache + - name: dshm + mountPath: /dev/shm + volumes: + - name: data + persistentVolumeClaim: + claimName: frigate-data + - name: media + persistentVolumeClaim: + claimName: frigate-media + - name: cache + persistentVolumeClaim: + claimName: frigate-cache + - name: dshm + emptyDir: + medium: Memory + sizeLimit: 1Gi + - name: configmap + configMap: + name: frigate-config diff --git a/apps/home/frigate/base/kustomization.yaml b/apps/home/frigate/base/kustomization.yaml new file mode 100644 index 000000000..72e1a7638 --- /dev/null +++ b/apps/home/frigate/base/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - deployment.yaml + - svc.yaml + - cm.yaml + - secret.yaml diff --git a/apps/home/frigate/base/secret.yaml b/apps/home/frigate/base/secret.yaml new file mode 100644 index 000000000..b66c0a78d --- /dev/null +++ b/apps/home/frigate/base/secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: frigate-vars + annotations: + avp.kubernetes.io/path: "kv/data/ha" +stringData: + FRIGATE_HA_TOKEN: diff --git a/apps/home/frigate/base/svc.yaml b/apps/home/frigate/base/svc.yaml new file mode 100644 index 000000000..53d6a7c74 --- /dev/null +++ b/apps/home/frigate/base/svc.yaml @@ -0,0 +1,51 @@ +apiVersion: v1 +kind: Service +metadata: + name: frigate-web + labels: + app: frigate +spec: + selector: + app: frigate + ports: + - name: web + port: 80 + targetPort: 5000 + protocol: TCP + type: ClusterIP +--- +apiVersion: v1 +kind: Service +metadata: + name: frigate-rtsp + labels: + app: frigate +spec: + selector: + app: frigate + ports: + - name: rtsp + port: 8554 + targetPort: 8554 + protocol: TCP + type: ClusterIP +--- +apiVersion: v1 +kind: Service +metadata: + name: frigate-webrtc + labels: + app: frigate +spec: + selector: + app: frigate + ports: + - name: webrtc-tcp + port: 8555 + targetPort: 8555 + protocol: TCP + - name: webrtc-udp + port: 8555 + targetPort: 8555 + protocol: UDP + type: ClusterIP diff --git a/apps/home/frigate/kustomization.yaml b/apps/home/frigate/kustomization.yaml new file mode 100644 index 000000000..d3bd44331 --- /dev/null +++ b/apps/home/frigate/kustomization.yaml @@ -0,0 +1,17 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./base + +namespace: homeassistant + +patches: + - patch: |- + - op: add + path: "/spec/template/spec/nodeSelector" + value: + kubernetes.io/arch: amd64 + kubernetes.io/hostname: node-one + target: + kind: Deployment + name: frigate