ソースを参照

Adds netboot.xyz (#2021)

* First cut to add netboot.xyz in community charts.

* Fix some linting issues, and things we don't need.

* Suggested version changes.

* Fix OEF

* Adjust port numbers.

* Adjust user to match container image.

* Update storage config.

* Set targetPort to match container image.

* Default hostNetwork to false.

* Update library/ix-dev/community/netbootxyz/ci/basic-values.yaml

Suggested fix.

Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>

* Update library/ix-dev/community/netbootxyz/templates/_persistence.tpl

Fix naming that was copied from elsewhere.

Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>

* Update helm dependencies.

* Configure NGINX to port 8080 and now we can default hostNetwork to true.  Also, run as root so the container can start properly.

* Streamline some things, as per suggestions.

* Remove permissions handling because the image handles this already.

* Fix tftpOpts list type.

* Update to common 1.2.9

* Fix EOF

* Remove permissions handling because the image handles this already.

* Fix TFTPD Options

* Fix upgrade strategy.

* Update library/ix-dev/community/netbootxyz/ci/basic-values.yaml

* Update library/ix-dev/community/netbootxyz/ci/basic-values.yaml

* Fix capabilities.

* Update capabilities and add some emptyDirs
Empty dirs added to reduce the time needed of chowning some dirs on startup

---------

Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
Co-authored-by: Stavros kois <s.kois@outlook.com>
Kelly Shutt 1 年間 前
コミット
53e9136512

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

@@ -0,0 +1,6 @@
+dependencies:
+- name: common
+  repository: file://../../../common
+  version: 1.2.9
+digest: sha256:af1a9a1f87e3e48453c9f25f909f5ebcd7fa6e25162b7b425448ba752bcdbc5c
+generated: "2024-01-23T17:10:13.3434522-05:00"

+ 30 - 0
library/ix-dev/community/netbootxyz/Chart.yaml

@@ -0,0 +1,30 @@
+name: netbootxyz
+description: netboot.xyz lets you PXE boot various operating system installers or utilities from a single tool over the network.
+annotations:
+  title: netbootxyz
+type: application
+version: 1.0.0
+apiVersion: v2
+appVersion: 2.0.76
+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.2.9
+home: https://github.com/truenas/charts/tree/master/community/netbootxyz
+icon: https://media.sys.truenas.net/apps/netbootxyz/icons/icon.svg
+sources:
+  - https://github.com/truenas/charts/tree/master/community/netbootxyz
+  - https://github.com/netbootxyz/docker-netbootxyz
+  - https://netboot.xyz
+keywords:
+  - tftp
+  - network
+  - pxe
+  - netboot
+  - netbootxyz
+  - netboot.xyz

+ 3 - 0
library/ix-dev/community/netbootxyz/README.md

@@ -0,0 +1,3 @@
+# netboot.xyz
+
+[netboot.xyz](https://netboot.xyz) lets you PXE boot various operating system installers or utilities from a single tool over the network.

+ 3 - 0
library/ix-dev/community/netbootxyz/app-readme.md

@@ -0,0 +1,3 @@
+# netboot.xyz
+
+[netboot.xyz](https://netboot.xyz) lets you PXE boot various operating system installers or utilities from a single tool over the network.

BIN
library/ix-dev/community/netbootxyz/charts/common-1.2.9.tgz


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

@@ -0,0 +1,10 @@
+netbootStorage:
+  config:
+    type: pvc
+  assets:
+    type: pvc
+netbootNetwork:
+  hostNetwork: true
+  tftpPort: 69
+  webHttpPort: 3000
+  webAssetsPort: 8080

+ 10 - 0
library/ix-dev/community/netbootxyz/item.yaml

@@ -0,0 +1,10 @@
+icon_url: https://media.sys.truenas.net/apps/netbootxyz/icons/icon.svg
+categories:
+  - network
+screenshots:
+  - https://media.sys.truenas.net/apps/netbootxyz/screenshots/screenshot1.jpg
+tags:
+  - tftp
+  - pxe
+  - netboot
+  - netboot.xyz

+ 22 - 0
library/ix-dev/community/netbootxyz/metadata.yaml

@@ -0,0 +1,22 @@
+runAsContext:
+  - userName: root
+    groupName: root
+    gid: 0
+    uid: 0
+    description: The container starts as root, then NGINX and TFTP spawn under normal user accounts.
+capabilities:
+  - name: CHOWN
+    description: TFTP requires this ability to set permissions for sub-processes.
+  - name: DAC_OVERRIDE
+    description: TFTP requires this ability to set permissions for sub-processes.
+  - name: FOWNER
+    description: TFTP requires this ability to set permissions for sub-processes.
+  - name: SETUID
+    description: TFTP requires this ability to switch user for sub-processes.
+  - name: SETGID
+    description: TFTP requires this ability to switch group for sub-processes.
+  - name: NET_BIND_SERVICE
+    description: TFTP requires this ability to bind to port 69 for TFTP.
+  - name: KILL
+    description: TFTP requires this ability to kill sub-processes.
+hostMounts: []

+ 321 - 0
library/ix-dev/community/netbootxyz/questions.yaml

@@ -0,0 +1,321 @@
+groups:
+  - name: netboot.xyz Configuration
+    description: Configure netboot.xyz.
+  - name: Network Configuration
+    description: Configure Network for netboot.xyz.
+  - name: Storage Configuration
+    description: Configure Storage for netboot.xyz
+  - name: Resources Configuration
+    description: Configure Resources for netboot.xyz
+
+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: TZ
+    group: netboot.xyz Configuration
+    label: Timezone
+    schema:
+      type: string
+      default: Etc/UTC
+      required: true
+      $ref:
+        - definitions/timezone
+
+  - variable: netbootConfig
+    label: ""
+    group: netboot.xyz Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: tftpdOpts
+          label: TFTPD Options
+          description: |
+            Additional TFTPD options.
+          schema:
+            type: list
+            default: []
+            items:
+              - variable: option
+                label: Option
+                schema:
+                  type: string
+                  required: true
+        - variable: additionalEnvs
+          label: Additional Environment Variables
+          description: Configure additional environment variables for netboot.xyz.
+          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: netbootNetwork
+    label: ""
+    group: Network Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: hostNetwork
+          label: Host Network
+          description: |
+            Bind to the host network. </br>
+            Required for TFTP.
+          schema:
+            type: boolean
+            default: true
+        - variable: tftpPort
+          label: TFTP Port
+          description: The TFTP port for netboot.xyz.
+          schema:
+            show_if: [["hostNetwork", "=", false]]
+            type: int
+            default: 31009
+            min: 9000
+            max: 65535
+            required: true
+        - variable: webHttpPort
+          label: Portal HTTP Port
+          description: The HTTP port for the netboot.xyz Portal.
+          schema:
+            show_if: [["hostNetwork", "=", false]]
+            type: int
+            default: 31010
+            min: 9000
+            max: 65535
+            required: true
+        - variable: webAssetsPort
+          label: Assets Port
+          description: The Assets port for the netboot.xyz, configures the NGINX_PORT variable on the container.
+          schema:
+            type: int
+            default: 31011
+            min: 9000
+            max: 65535
+            required: true
+
+  - variable: netbootStorage
+    label: ""
+    group: Storage Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: config
+          label: netboot.xyz Config Storage
+          description: The path to store netboot.xyz 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
+                  immutable: 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: ixVolumeConfig
+                label: ixVolume Configuration
+                description: The configuration for the ixVolume dataset.
+                schema:
+                  type: dict
+                  show_if: [["type", "=", "ixVolume"]]
+                  $ref:
+                    - "normalize/ixVolume"
+                  attrs:
+                    - variable: aclEnable
+                      label: Enable ACL
+                      description: Enable ACL for the dataset.
+                      schema:
+                        type: boolean
+                        default: false
+                    - variable: datasetName
+                      label: Dataset Name
+                      description: The name of the dataset to use for storage.
+                      schema:
+                        type: string
+                        required: true
+                        immutable: true
+                        hidden: true
+                        default: "config"
+                    - variable: aclEntries
+                      label: ACL Configuration
+                      schema:
+                        type: dict
+                        show_if: [["aclEnable", "=", true]]
+                        attrs: []
+              - variable: hostPathConfig
+                label: Host Path Configuration
+                schema:
+                  type: dict
+                  show_if: [["type", "=", "hostPath"]]
+                  attrs:
+                    - variable: aclEnable
+                      label: Enable ACL
+                      description: Enable ACL for the dataset.
+                      schema:
+                        type: boolean
+                        default: false
+                    - variable: acl
+                      label: ACL Configuration
+                      schema:
+                        type: dict
+                        show_if: [["aclEnable", "=", true]]
+                        attrs: []
+                        $ref:
+                          - "normalize/acl"
+                    - variable: hostPath
+                      label: Host Path
+                      description: The host path to use for storage.
+                      schema:
+                        type: hostpath
+                        show_if: [["aclEnable", "=", false]]
+                        required: true
+
+        - variable: assets
+          label: netboot.xyz Assets Storage
+          description: The path to store netboot.xyz 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
+                  immutable: 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: ixVolumeConfig
+                label: ixVolume Configuration
+                description: The configuration for the ixVolume dataset.
+                schema:
+                  type: dict
+                  show_if: [["type", "=", "ixVolume"]]
+                  $ref:
+                    - "normalize/ixVolume"
+                  attrs:
+                    - variable: aclEnable
+                      label: Enable ACL
+                      description: Enable ACL for the dataset.
+                      schema:
+                        type: boolean
+                        default: false
+                    - variable: datasetName
+                      label: Dataset Name
+                      description: The name of the dataset to use for storage.
+                      schema:
+                        type: string
+                        required: true
+                        immutable: true
+                        hidden: true
+                        default: "assets"
+                    - variable: aclEntries
+                      label: ACL Configuration
+                      schema:
+                        type: dict
+                        show_if: [["aclEnable", "=", true]]
+                        attrs: []
+              - variable: hostPathConfig
+                label: Host Path Configuration
+                schema:
+                  type: dict
+                  show_if: [["type", "=", "hostPath"]]
+                  attrs:
+                    - variable: aclEnable
+                      label: Enable ACL
+                      description: Enable ACL for the dataset.
+                      schema:
+                        type: boolean
+                        default: false
+                    - variable: acl
+                      label: ACL Configuration
+                      schema:
+                        type: dict
+                        show_if: [["aclEnable", "=", true]]
+                        attrs: []
+                        $ref:
+                          - "normalize/acl"
+                    - variable: hostPath
+                      label: Host Path
+                      description: The host path to use for storage.
+                      schema:
+                        type: hostpath
+                        show_if: [["aclEnable", "=", false]]
+                        required: true
+
+  - 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 netboot.xyz.
+                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 netboot.xyz.
+                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/netbootxyz/templates/NOTES.txt

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

+ 63 - 0
library/ix-dev/community/netbootxyz/templates/_netboot.tpl

@@ -0,0 +1,63 @@
+{{- define "netboot.workload" -}}
+workload:
+  netboot:
+    enabled: true
+    primary: true
+    type: Deployment
+    podSpec:
+      hostNetwork: {{ .Values.netbootNetwork.hostNetwork }}
+      containers:
+        netboot:
+          enabled: true
+          primary: true
+          imageSelector: image
+          securityContext:
+            runAsNonRoot: false
+            runAsUser: 0
+            runAsGroup: 0
+            readOnlyRootFilesystem: false
+            capabilities:
+              add:
+                - CHOWN
+                - DAC_OVERRIDE
+                - FOWNER
+                - SETGID
+                - SETUID
+                - NET_BIND_SERVICE
+                - KILL
+          env:
+            NGINX_PORT: {{ .Values.netbootNetwork.webAssetsPort }}
+            TFTPD_OPTS: {{ join " " .Values.netbootConfig.tftpdOpts }}
+          {{ with .Values.netbootConfig.additionalEnvs }}
+          envList:
+            {{ range $env := . }}
+            - name: {{ $env.name }}
+              value: {{ $env.value }}
+            {{ end }}
+          {{ end }}
+          probes:
+            liveness:
+              enabled: true
+              type: exec
+              command:
+                - /bin/sh
+                - -c
+                - |
+                  pgrep in.tftpd
+            readiness:
+              enabled: true
+              type: exec
+              command:
+                - /bin/sh
+                - -c
+                - |
+                  pgrep in.tftpd
+            startup:
+              enabled: true
+              type: exec
+              command:
+                - /bin/sh
+                - -c
+                - |
+                  pgrep in.tftpd
+{{- end -}}

+ 47 - 0
library/ix-dev/community/netbootxyz/templates/_persistence.tpl

@@ -0,0 +1,47 @@
+{{- define "netboot.persistence" -}}
+persistence:
+  config:
+    enabled: true
+    {{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.netbootStorage.config) | nindent 4 }}
+    targetSelector:
+      netboot:
+        netboot:
+          mountPath: /config
+  assets:
+    enabled: true
+    {{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.netbootStorage.assets) | nindent 4 }}
+    targetSelector:
+      netboot:
+        netboot:
+          mountPath: /assets
+  tmp:
+    enabled: true
+    type: emptyDir
+    targetSelector:
+      netboot:
+        netboot:
+          mountPath: /tmp
+  varlognginx:
+    enabled: true
+    type: emptyDir
+    targetSelector:
+      netboot:
+        netboot:
+          mountPath: /var/log/nginx
+  vartmpnginx:
+    enabled: true
+    type: emptyDir
+    targetSelector:
+      netboot:
+        netboot:
+          mountPath: /var/tmp/nginx
+  {{- range $idx, $storage := .Values.netbootStorage.additionalStorages }}
+  {{ printf "netboot-%v" (int $idx) }}:
+    enabled: true
+    {{- include "ix.v1.common.app.storageOptions" (dict "storage" $storage) | nindent 4 }}
+    targetSelector:
+      netboot:
+        netboot:
+          mountPath: {{ $storage.mountPath }}
+  {{- end -}}
+{{- end -}}

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

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

+ 34 - 0
library/ix-dev/community/netbootxyz/templates/_service.tpl

@@ -0,0 +1,34 @@
+{{- define "netboot.service" -}}
+service:
+  netboot:
+    enabled: true
+    primary: true
+    type: NodePort
+    targetSelector: netboot
+    ports:
+      tftp:
+        enabled: true
+        primary: true
+        port: {{ .Values.netbootNetwork.tftpPort }}
+        nodePort: {{ .Values.netbootNetwork.tftpPort }}
+        targetPort: 69
+        protocol: udp
+        targetSelector: netboot
+      assets:
+        enabled: true
+        port: {{ .Values.netbootNetwork.webAssetsPort }}
+        nodePort: {{ .Values.netbootNetwork.webAssetsPort }}
+        targetSelector: netboot
+  netboot-portal:
+    enabled: true
+    type: NodePort
+    targetSelector: netboot
+    ports:
+      portal-http:
+        enabled: true
+        primary: true
+        port: {{ .Values.netbootNetwork.webHttpPort }}
+        nodePort: {{ .Values.netbootNetwork.webHttpPort }}
+        targetPort: 3000
+        targetSelector: netboot
+{{- end -}}

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

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

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

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

+ 31 - 0
library/ix-dev/community/netbootxyz/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'\d+\.\d+\.\d+-nbxyz2')
+
+
+def newer_mapping(image_tags):
+    key = list(image_tags.keys())[0]
+    tags = {t.strip('-nbxyz2'): 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)))

+ 31 - 0
library/ix-dev/community/netbootxyz/values.yaml

@@ -0,0 +1,31 @@
+image:
+  repository: netbootxyz/netbootxyz
+  pullPolicy: IfNotPresent
+  tag: 0.7.0-nbxyz2
+
+resources:
+  limits:
+    cpu: 4000m
+    memory: 8Gi
+
+netbootConfig:
+  tftpdOpts: []
+  additionalEnvs: []
+
+netbootNetwork:
+  # TFTP only works with hostNetwork: true
+  hostNetwork: true
+  tftpPort: 69
+  webHttpPort: 3000
+  webAssetsPort: 8080
+
+netbootStorage:
+  config:
+    type: ixVolume
+    ixVolumeConfig:
+      datasetName: config
+  assets:
+    type: ixVolume
+    ixVolumeConfig:
+      datasetName: assets
+  additionalStorages: []