Преглед на файлове

Update plex chart format

Waqar Ahmed преди 4 години
родител
ревизия
17966e2927
променени са 3 файла, в които са добавени 159 реда и са изтрити 145 реда
  1. 16 0
      test/plex/1.0.1/migrations/migrate.py
  2. 137 106
      test/plex/1.0.1/questions.yaml
  3. 6 39
      test/plex/1.0.1/templates/deployment.yaml

+ 16 - 0
test/plex/1.0.1/migrations/migrate.py

@@ -0,0 +1,16 @@
+def migrate(values):
+    values['appVolumeMounts'] = {
+        'transcode': {
+            'hostPathEnabled': values['transcodeHostPathEnabled'],
+            **({'hostPath': values['transcodeHostPath']} if values.get('transcodeHostPath') else {})
+        },
+        'config': {
+            'hostPathEnabled': values['configHostPathEnabled'],
+            **({'hostPath': values['configHostPath']} if values.get('configHostPath') else {})
+        },
+        'data': {
+            'hostPathEnabled': values['dataHostPathEnabled'],
+            **({'hostPath': values['dataHostPath']} if values.get('dataHostPath') else {})
+        },
+    }
+    return values

+ 137 - 106
test/plex/1.0.1/questions.yaml

@@ -141,122 +141,153 @@ questions:
             max: 65535
             default: 32400
 
-  - variable: transcodeHostPathEnabled
-    label: "Configure Host Path for Transcode"
-    group: "Storage"
-    schema:
-      type: boolean
-      default: false
-      show_subquestions_if: true
-      subquestions:
-        - variable: transcodeHostPath
-          label: "Specify HostPath for Transcode"
-          schema:
-            type: hostpath
-            required: true
-
-  - variable: transcodeVolume
-    label: "Transcode Volume Defaults"
-    group: "Storage"
+  # Specify GPU configuration
+  - variable: gpuConfiguration
+    label: "GPU Configuration"
+    group: "Resource Reservation"
     schema:
       type: dict
-      show_if: [["transcodeHostPathEnabled", "=", false]]
       $ref:
-        - "normalize/ixVolume"
-      attrs:
-        - variable: mountPath
-          label: "Mount Path"
-          description: "Path where the volume will be mounted inside the pod"
-          schema:
-            type: path
-            editable: false
-            default: "/transcode"
-        - variable: datasetName
-          label: "Transcode Dataset Name"
-          schema:
-            type: string
-            default: "ix-plex_transcode"
-            editable: false
-
-  - variable: dataHostPathEnabled
-    label: "Configure Host Path for Data"
-    group: "Storage"
-    schema:
-      type: boolean
-      default: false
-      show_subquestions_if: true
-      subquestions:
-        - variable: dataHostPath
-          label: "Specify HostPath for Data"
-          schema:
-            type: hostpath
-            required: true
+        - "definitions/gpuConfiguration"
 
-  - variable: dataVolume
-    label: "Data Volume Defaults"
+  - variable: appVolumeMounts
+    label: "Plex Storage"
     group: "Storage"
     schema:
       type: dict
-      show_if: [["dataHostPathEnabled", "=", false]]
-      $ref:
-        - "normalize/ixVolume"
       attrs:
-        - variable: mountPath
-          label: "Mount Path"
-          description: "Path where the volume will be mounted inside the pod"
+        - variable: transcode
+          label: "Transcode Volume"
           schema:
-            type: path
-            editable: false
-            default: "/data"
-        - variable: datasetName
-          label: "Data Dataset Name"
+            type: dict
+            attrs:
+              - variable: datasetName
+                label: "Plex Transcode Volume Dataset Name"
+                schema:
+                  type: string
+                  $ref:
+                    - "normalize/ixVolume"
+                  show_if: [["hostPathEnabled", "=", false]]
+                  default: "ix-plex_transcode"
+                  editable: false
+              - variable: mountPath
+                label: "Plex Transcode Mount Path"
+                description: "Path where the volume will be mounted inside the pod"
+                schema:
+                  type: path
+                  editable: false
+                  default: "/transcode"
+              - variable: hostPathEnabled
+                label: "Enable Host Path for Plex Transcode Volume"
+                schema:
+                  type: boolean
+                  default: false
+                  show_subquestions_if: true
+                  subquestions:
+                    - variable: hostPath
+                      label: "Host Path for Plex Transcode Volume"
+                      schema:
+                        type: hostpath
+                        required: true
+        - variable: data
+          label: "Data Volume"
           schema:
-            type: string
-            default: "ix-plex_data"
-            editable: false
-
-  - variable: configHostPathEnabled
-    label: "Configure Host Path for Config"
-    group: "Storage"
-    schema:
-      type: boolean
-      default: false
-      show_subquestions_if: true
-      subquestions:
-        - variable: configHostPath
-          label: "Specify HostPath for Config"
+            type: dict
+            attrs:
+              - variable: datasetName
+                label: "Plex Data Volume Dataset Name"
+                schema:
+                  type: string
+                  $ref:
+                    - "normalize/ixVolume"
+                  show_if: [["hostPathEnabled", "=", false]]
+                  default: "ix-plex_data"
+                  editable: false
+              - variable: mountPath
+                label: "Plex Data Mount Path"
+                description: "Path where the volume will be mounted inside the pod"
+                schema:
+                  type: path
+                  editable: false
+                  default: "/data"
+              - variable: hostPathEnabled
+                label: "Enable Host Path for Plex Data Volume"
+                schema:
+                  type: boolean
+                  default: false
+                  show_subquestions_if: true
+                  subquestions:
+                    - variable: hostPath
+                      label: "Host Path for Plex Data Volume"
+                      schema:
+                        type: hostpath
+                        required: true
+        - variable: config
+          label: "Config Volume"
           schema:
-            type: hostpath
-            required: true
-
-  - variable: configVolume
-    label: "Configuration Volume Defaults"
-    group: "Storage"
-    schema:
-      type: dict
-      show_if: [["configHostPathEnabled", "=", false]]
-      $ref:
-        - "normalize/ixVolume"
-      attrs:
-        - variable: mountPath
-          label: "Mount Path"
-          description: "Path where the volume will be mounted inside the pod"
+            type: dict
+            attrs:
+              - variable: datasetName
+                label: "Plex Config Volume Dataset Name"
+                schema:
+                  type: string
+                  $ref:
+                    - "normalize/ixVolume"
+                  show_if: [["hostPathEnabled", "=", false]]
+                  default: "ix-plex_config"
+                  editable: false
+              - variable: mountPath
+                label: "Plex Config Mount Path"
+                description: "Path where the volume will be mounted inside the pod"
+                schema:
+                  type: path
+                  editable: false
+                  default: "/config"
+              - variable: hostPathEnabled
+                label: "Enable Host Path for Plex Config Volume"
+                schema:
+                  type: boolean
+                  default: false
+                  show_subquestions_if: true
+                  subquestions:
+                    - variable: hostPath
+                      label: "Host Path for Plex Config Volume"
+                      schema:
+                        type: hostpath
+                        required: true
+        - variable: shared
+          label: "Shared Volume"
           schema:
-            type: path
-            editable: false
-            default: "/config"
-        - variable: datasetName
-          label: "Configuration Dataset Name"
+            type: dict
+            attrs:
+              - variable: emptyDir
+                label: "Temporary Volume"
+                schema:
+                  type: boolean
+                  default: true
+                  editable: false
+              - variable: mountPath
+                label: "Plex Shared Mount Path"
+                description: "Path where the volume will be mounted inside the pod"
+                schema:
+                  type: path
+                  editable: false
+                  default: "/shared"
+        - variable: shared-logs
+          label: "Shared Logs Volume"
           schema:
-            type: string
-            default: "ix-plex_config"
-            editable: false
-
-  # Specify GPU configuration
-  - variable: gpuConfiguration
-    label: "GPU Configuration"
-    group: "Resource Reservation"
-    schema:
-      type: dict
-      $ref:
-        - "definitions/gpuConfiguration"
+            type: dict
+            attrs:
+              - variable: emptyDir
+                label: "Temporary Volume"
+                schema:
+                  type: boolean
+                  default: true
+                  editable: false
+              - variable: mountPath
+                label: "Plex Shared Logs Mount Path"
+                description: "Path where the volume will be mounted inside the pod"
+                schema:
+                  type: path
+                  editable: false
+                  default: "/config/Library/Application Support/Plex Media Server/Logs"

+ 6 - 39
test/plex/1.0.1/templates/deployment.yaml

@@ -1,19 +1,8 @@
 apiVersion: apps/v1
 kind: Deployment
-metadata:
-  name: {{ include "common.names.fullname" . }}
-  labels: {{ include "common.labels" . | nindent 4 }}
-spec:
-  replicas: 1
-  revisionHistoryLimit: 3
-  strategy:
-    type: {{ .Values.strategyType }}
-  selector:
-    matchLabels: {{ include "common.labels.selectorLabels" . | nindent 6 }}
-  template:
-    metadata:
-      labels: {{ include "common.labels.selectorLabels" . | nindent 8 }}
-      annotations: {{ include "common.annotations" . | nindent 8 }}
+{{ include "common.deployment.metadata" . | nindent 0 }}
+spec: {{ include "common.deployment.common_spec" . | nindent 2 }}
+  template: {{ include "common.deployment.pod.metadata" . | nindent 4 }}
     spec:
     {{- if .Values.hostNetwork }}
       hostNetwork: {{ .Values.hostNetwork }}
@@ -22,6 +11,8 @@ spec:
       containers:
         - name: {{ .Chart.Name }}
           {{ include "common.containers.imageConfig" .Values.image | nindent 10 }}
+          {{ include "common.storage.allContainerVolumeMounts" .Values | nindent 10 }}
+          {{ include "common.containers.gpuConfiguration" .Values | nindent 10 }}
           ports:
           - name: pms
             protocol: TCP
@@ -77,28 +68,4 @@ spec:
             initialDelaySeconds: 5
             failureThreshold: 40
             periodSeconds: 15
-          volumeMounts:
-          - name: data
-            mountPath: /data
-          - name: config
-            mountPath: /config
-          - name: transcode
-            mountPath: /transcode
-          - name: shared
-            mountPath: /shared
-          - name: shared-logs
-            mountPath: "/config/Library/Application Support/Plex Media Server/Logs"
-          {{- if .Values.gpuConfiguration }}
-          resources:
-            limits:
-              {{- toYaml .Values.gpuConfiguration | nindent 14 }}
-          {{- end }}
-      volumes:
-        {{ $emptyDir := .Values.emptyDirVolumes }}
-        {{ $vols := list }}
-        {{ $vols = mustAppend $vols (dict "name" "data" "emptyDirVolumes" $emptyDir "hostPathEnabled" .Values.dataHostPathEnabled "pathField" .Values.dataHostPath "datasetName" (.Values.dataVolume | default dict).datasetName ) }}
-        {{ $vols = mustAppend $vols (dict "name" "config" "emptyDirVolumes" $emptyDir "hostPathEnabled" .Values.configHostPathEnabled "pathField" .Values.configHostPath "datasetName" (.Values.configVolume | default dict).datasetName ) }}
-        {{ $vols = mustAppend $vols (dict "name" "transcode" "emptyDirVolumes" $emptyDir "hostPathEnabled" .Values.transcodeHostPathEnabled "pathField" .Values.transcodeHostPath "datasetName" (.Values.transcodeVolume | default dict).datasetName ) }}
-        {{ $vols = mustAppend $vols (dict "name" "shared" "emptyDirVolumes" true "hostPathEnabled" false "pathField" nil "datasetName" nil) }}
-        {{ $vols = mustAppend $vols (dict "name" "shared-logs" "emptyDirVolumes" true "hostPathEnabled" false "pathField" nil "datasetName" nil) }}
-        {{ include "common.storage.volumesConfiguration" (dict "ixVolumes" .Values.ixVolumes "volumes" $vols) | nindent 8 }}
+{{ include "common.storage.allAppVolumes" .Values | nindent 6 }}