Parcourir la source

frigate - Allow selecting different image (eg tensorrt) (#1821)

Stavros Kois il y a 1 an
Parent
commit
e703ecbac3

+ 1 - 1
library/ix-dev/community/frigate/Chart.yaml

@@ -3,7 +3,7 @@ description: Frigate is an NVR With Realtime Object Detection for IP Cameras
 annotations:
   title: Frigate
 type: application
-version: 1.1.3
+version: 1.1.4
 apiVersion: v2
 appVersion: 0.12.1
 kubeVersion: '>=1.16.0-0'

+ 12 - 0
library/ix-dev/community/frigate/questions.yaml

@@ -25,6 +25,18 @@ questions:
     schema:
       type: dict
       attrs:
+        - variable: imageSelector
+          label: Image
+          description: The image to use for Frigate.
+          schema:
+            type: string
+            default: "image"
+            required: true
+            enum:
+              - value: image
+                description: Frigate Image
+              - value: tensorrtImage
+                description: Frigate TensorRT Image
         - variable: mountUSBBus
           label: Mount USB Bus
           description: |

+ 1 - 1
library/ix-dev/community/frigate/templates/_frigate.tpl

@@ -10,7 +10,7 @@ workload:
         frigate:
           enabled: true
           primary: true
-          imageSelector: image
+          imageSelector: {{ .Values.frigateConfig.imageSelector | default "image" }}
           securityContext:
             runAsUser: 0
             runAsGroup: 0

+ 1 - 1
library/ix-dev/community/frigate/upgrade_info.json

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

+ 34 - 10
library/ix-dev/community/frigate/upgrade_strategy

@@ -6,21 +6,45 @@ import sys
 from catalog_update.upgrade_strategy import semantic_versioning
 
 
-RE_STABLE_VERSION = re.compile(r'\d+\.\d+\.\d+')
+RE_STABLE_VERSION_BASE = r'\d+\.\d+\.\d+'
+ENUMS = {
+    'image': {
+        'RE_STABLE_VERSION': re.compile(RE_STABLE_VERSION_BASE),
+        'STRIP_TEXT': ''
+    },
+    'tensorrtImage': {
+        'RE_STABLE_VERSION': re.compile(rf'{RE_STABLE_VERSION_BASE}-tensorrt'),
+        'STRIP_TEXT': '-tensorrt'
+    },
+}
 
 
 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,
+    output = {
+        "tags": {},
+        "app_version": ""
     }
 
+    for key in image_tags.keys():
+        STRIP_TEXT = ENUMS[key].get('STRIP_TEXT', None) if key in ENUMS else None
+        RE_STABLE_VERSION = ENUMS[key].get('RE_STABLE_VERSION', None) if key in ENUMS else None
+
+        if (STRIP_TEXT is None) or (RE_STABLE_VERSION is None):
+            continue
+
+        tags = {t.strip(STRIP_TEXT): t for t in image_tags[key] if RE_STABLE_VERSION.fullmatch(t)}
+        version = semantic_versioning(list(tags))
+
+        if not version:
+            continue
+
+        if key == 'image':
+            output['app_version'] = version
+
+        output['tags'][key] = tags[version]
+
+    return output
+
 
 if __name__ == '__main__':
     try:

+ 6 - 0
library/ix-dev/community/frigate/values.yaml

@@ -3,12 +3,18 @@ image:
   pullPolicy: IfNotPresent
   tag: 0.12.1
 
+tensorrtImage:
+  repository: ghcr.io/blakeblackshear/frigate
+  pullPolicy: IfNotPresent
+  tag: 0.12.1-tensorrt
+
 resources:
   limits:
     cpu: 4000m
     memory: 8Gi
 
 frigateConfig:
+  imageSelector: image
   mountUSBBus: false
   additionalEnvs: []