Forráskód Böngészése

add `homer` to `community` train (#1631)

* add `homer` to `community` train

* add common

* add metadata and readme

* add templates

* more ci values

* add questions

* rename to assets
Stavros Kois 1 éve
szülő
commit
561c234988

+ 6 - 0
library/ix-dev/community/homer/Chart.lock

@@ -0,0 +1,6 @@
+dependencies:
+- name: common
+  repository: file://../../../common
+  version: 1.1.1
+digest: sha256:a7dbe3e4d42dbcd4325776e5e01a1d630c7f185f79e7ebf22b1b9cc80f56eed7
+generated: "2023-10-10T16:12:08.426497312+03:00"

+ 26 - 0
library/ix-dev/community/homer/Chart.yaml

@@ -0,0 +1,26 @@
+name: homer
+description: Homer is a dead simple static HOMepage for your servER to keep your services on hand, from a simple yaml configuration file.
+annotations:
+  title: Homer
+type: application
+version: 1.0.0
+apiVersion: v2
+appVersion: v23.09.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.1.1
+home: https://github.com/bastienwirtz/homer
+icon: https://raw.githubusercontent.com//bastienwirtz/homer/main/public/logo.png
+sources:
+  - https://hub.docker.com/r/b4bz/homer
+  - https://github.com/truenas/charts/tree/master/library/ix-dev/community/homer
+  - https://github.com/bastienwirtz/homer
+keywords:
+  - dashboard
+  - homepage

+ 8 - 0
library/ix-dev/community/homer/README.md

@@ -0,0 +1,8 @@
+# Homer
+
+[Homer](https://github.com/bastienwirtz/homer) is a dead simple static HOMepage for your servER to keep your services on hand, from a simple yaml configuration file.
+
+> When application is installed, a container will be launched with **root** privileges.
+> This is required in order to apply the correct permissions to the `Homer` directories.
+> Afterward, the `Homer` container will run as a **non**-root user (Default: `568`).
+> All mounted storage(s) will be `chown`ed only if the parent directory does not match the configured user.

+ 8 - 0
library/ix-dev/community/homer/app-readme.md

@@ -0,0 +1,8 @@
+# Homer
+
+[Homer](https://github.com/bastienwirtz/homer) is a dead simple static HOMepage for your servER to keep your services on hand, from a simple yaml configuration file.
+
+> When application is installed, a container will be launched with **root** privileges.
+> This is required in order to apply the correct permissions to the `Homer` directories.
+> Afterward, the `Homer` container will run as a **non**-root user (Default: `568`).
+> All mounted storage(s) will be `chown`ed only if the parent directory does not match the configured user.

BIN
library/ix-dev/community/homer/charts/common-1.1.1.tgz


+ 10 - 0
library/ix-dev/community/homer/ci/basic-values.yaml

@@ -0,0 +1,10 @@
+homerNetwork:
+  webPort: 31000
+
+homerRunAs:
+  user: 1000
+  group: 1000
+
+homerStorage:
+  assets:
+    type: pvc

+ 14 - 0
library/ix-dev/community/homer/ci/extra-values.yaml

@@ -0,0 +1,14 @@
+homerConfig:
+  initAssets: true
+
+homerNetwork:
+  webPort: 31000
+
+homerStorage:
+  assets:
+    type: pvc
+  additionalStorages:
+  - type: pvc
+    mountPath: /data1
+  - type: pvc
+    mountPath: /data2

+ 7 - 0
library/ix-dev/community/homer/ci/hostNet-values.yaml

@@ -0,0 +1,7 @@
+homerNetwork:
+  webPort: 30000
+  hostNetwork: true
+
+homerStorage:
+  assets:
+    type: pvc

+ 8 - 0
library/ix-dev/community/homer/item.yaml

@@ -0,0 +1,8 @@
+icon_url: https://raw.githubusercontent.com//bastienwirtz/homer/main/public/logo.png
+categories:
+  - productivity
+screenshots:
+  - https://camo.githubusercontent.com/22f0b90b2c9ec4f1c9ec9ed920bb7b794bc1f1ac93bf61099ef298369b8850e5/68747470733a2f2f7261772e6769746875622e636f6d2f6261737469656e776972747a2f686f6d65722f6d61696e2f646f63732f73637265656e73686f742e706e67
+tags:
+  - dashboard
+  - homepage

+ 8 - 0
library/ix-dev/community/homer/metadata.yaml

@@ -0,0 +1,8 @@
+runAsContext:
+  - userName: homer
+    groupName: homer
+    gid: 568
+    uid: 568
+    description: Homer can run as any non-root user.
+capabilities: []
+hostMounts: []

+ 239 - 0
library/ix-dev/community/homer/questions.yaml

@@ -0,0 +1,239 @@
+groups:
+  - name: Homer Configuration
+    description: Configure Homer
+  - name: User and Group Configuration
+    description: Configure User and Group for Homer
+  - name: Network Configuration
+    description: Configure Network for Homer
+  - name: Storage Configuration
+    description: Configure Storage for Homer
+  - name: Resources Configuration
+    description: Configure Resources for Homer
+
+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: homerConfig
+    label: ""
+    group: Homer Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: initAssets
+          label: Init Assets
+          description: Install example configuration file & assets to help you get started.
+          schema:
+            type: boolean
+            default: false
+        - variable: additionalEnvs
+          label: Additional Environment Variables
+          description: Configure additional environment variables for Homer.
+          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: homerRunAs
+    label: ""
+    group: User and Group Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: user
+          label: User ID
+          description: The user id that Homer will run as.
+          schema:
+            type: int
+            min: 2
+            default: 568
+            required: true
+        - variable: group
+          label: Group ID
+          description: The group id that Homer will run as.
+          schema:
+            type: int
+            min: 2
+            default: 568
+            required: true
+
+  - variable: homerNetwork
+    label: ""
+    group: Network Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: webPort
+          label: Web Port
+          description: The port for the Homer Web UI.
+          schema:
+            type: int
+            default: 30092
+            min: 9000
+            max: 65535
+            required: true
+        - variable: hostNetwork
+          label: Host Network
+          description: |
+            Bind to the host network. It's recommended to keep this disabled.</br>
+          schema:
+            type: boolean
+            default: false
+
+  - variable: homerStorage
+    label: ""
+    group: Storage Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: assets
+          label: Homer Assets Storage
+          description: The path to store Homer Assets.
+          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: "assets"
+                  $ref:
+                    - "normalize/ixVolume"
+              - variable: hostPath
+                label: Host Path
+                schema:
+                  type: hostpath
+                  show_if: [["type", "=", "hostPath"]]
+                  immutable: true
+                  required: true
+        - variable: additionalStorages
+          label: Additional Storage
+          description: Additional storage for Homer.
+          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 Homer.
+                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 Homer.
+                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

+ 1 - 0
library/ix-dev/community/homer/templates/NOTES.txt

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

+ 49 - 0
library/ix-dev/community/homer/templates/_homer.tpl

@@ -0,0 +1,49 @@
+{{- define "homer.workload" -}}
+workload:
+  homer:
+    enabled: true
+    primary: true
+    type: Deployment
+    podSpec:
+      hostNetwork: {{ .Values.homerNetwork.hostNetwork }}
+      containers:
+        homer:
+          enabled: true
+          primary: true
+          imageSelector: image
+          securityContext:
+            runAsUser: {{ .Values.homerRunAs.user }}
+            runAsGroup: {{ .Values.homerRunAs.group }}
+          env:
+            PORT: {{ .Values.homerNetwork.webPort }}
+            INIT_ASSETS: {{ ternary "1" "0" .Values.homerConfig.initAssets }}
+          {{ with .Values.homerConfig.additionalEnvs }}
+          envList:
+            {{ range $env := . }}
+            - name: {{ $env.name }}
+              value: {{ $env.value }}
+            {{ end }}
+          {{ end }}
+          probes:
+            liveness:
+              enabled: true
+              type: http
+              port: {{ .Values.homerNetwork.webPort }}
+              path: /
+            readiness:
+              enabled: true
+              type: http
+              port: {{ .Values.homerNetwork.webPort }}
+              path: /
+            startup:
+              enabled: true
+              type: http
+              port: {{ .Values.homerNetwork.webPort }}
+              path: /
+      initContainers:
+      {{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions"
+                                                        "UID" .Values.homerRunAs.user
+                                                        "GID" .Values.homerRunAs.group
+                                                        "mode" "check"
+                                                        "type" "init") | nindent 8 }}
+{{- end -}}

+ 34 - 0
library/ix-dev/community/homer/templates/_persistence.tpl

@@ -0,0 +1,34 @@
+{{- define "homer.persistence" -}}
+persistence:
+  assets:
+    enabled: true
+    type: {{ .Values.homerStorage.assets.type }}
+    datasetName: {{ .Values.homerStorage.assets.datasetName | default "" }}
+    hostPath: {{ .Values.homerStorage.assets.hostPath | default "" }}
+    targetSelector:
+      homer:
+        homer:
+          mountPath: /www/assets
+        01-permissions:
+          mountPath: /mnt/directories/assets
+  tmp:
+    enabled: true
+    type: emptyDir
+    targetSelector:
+      homer:
+        homer:
+          mountPath: /tmp
+  {{- range $idx, $storage := .Values.homerStorage.additionalStorages }}
+  {{ printf "homer-%v" (int $idx) }}:
+    enabled: true
+    type: {{ $storage.type }}
+    datasetName: {{ $storage.datasetName | default "" }}
+    hostPath: {{ $storage.hostPath | default "" }}
+    targetSelector:
+      homer:
+        homer:
+          mountPath: {{ $storage.mountPath }}
+        01-permissions:
+          mountPath: /mnt/directories{{ $storage.mountPath }}
+  {{- end }}
+{{- end -}}

+ 12 - 0
library/ix-dev/community/homer/templates/_portal.tpl

@@ -0,0 +1,12 @@
+{{- define "homer.portal" -}}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: portal
+data:
+  path: "/"
+  port: {{ .Values.homerNetwork.webPort | quote }}
+  protocol: http
+  host: $node_ip
+{{- end -}}

+ 15 - 0
library/ix-dev/community/homer/templates/_service.tpl

@@ -0,0 +1,15 @@
+{{- define "homer.service" -}}
+service:
+  homer:
+    enabled: true
+    primary: true
+    type: NodePort
+    targetSelector: homer
+    ports:
+      webui:
+        enabled: true
+        primary: true
+        port: {{ .Values.homerNetwork.webPort }}
+        nodePort: {{ .Values.homerNetwork.webPort }}
+        targetSelector: homer
+{{- end -}}

+ 11 - 0
library/ix-dev/community/homer/templates/common.yaml

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

+ 1 - 0
library/ix-dev/community/homer/upgrade_info.json

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

+ 31 - 0
library/ix-dev/community/homer/upgrade_strategy

@@ -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'v\d+\.\d+\.\d+')
+
+
+def newer_mapping(image_tags):
+    key = list(image_tags.keys())[0]
+    tags = {t.strip('v'): 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)))

+ 27 - 0
library/ix-dev/community/homer/values.yaml

@@ -0,0 +1,27 @@
+image:
+  repository: b4bz/homer
+  pullPolicy: IfNotPresent
+  tag: v23.09.1
+
+resources:
+  limits:
+    cpu: 4000m
+    memory: 8Gi
+
+homerConfig:
+  initAssets: false
+  additionalEnvs: []
+
+homerNetwork:
+  webPort: 30092
+  hostNetwork: false
+
+homerRunAs:
+  user: 568
+  group: 568
+
+homerStorage:
+  assets:
+    type: ixVolume
+    datasetName: assets
+  additionalStorages: []