diff --git a/README.md b/README.md index 741cdbc8a..79fabc466 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ helm delete my- | [Domain Watch domain-watch icon](charts/domain-watch/) | Tool to watch whois reports and notify when statuses change or expiration is incoming. | | [Home Assistant esphome icon](charts/esphome/) | ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems. | | [Flame flame icon](charts/flame/) | Flame is self-hosted startpage for your server. Easily manage your apps and bookmarks with built-in editors. | +| [Generic Device Plugin ](charts/generic-device-plugin/) | The generic-device-plugin enables allocating generic Linux devices, such as serial devices, the FUSE device, or video cameras, to Kubernetes Pods | | [Hammond hammond icon](charts/hammond/) | A self-hosted vehicle expense tracking system with support for multiple users. | | [Headscale headscale icon](charts/headscale/) | An open source, self-hosted implementation of the Tailscale control server. | | [Healthchecks healthchecks icon](charts/healthchecks/) | A cron monitoring tool written in Python & Django | diff --git a/charts/generic-device-plugin/.helmignore b/charts/generic-device-plugin/.helmignore new file mode 100644 index 000000000..f56cea6b7 --- /dev/null +++ b/charts/generic-device-plugin/.helmignore @@ -0,0 +1,25 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ +# helm-docs templates +*.gotmpl diff --git a/charts/generic-device-plugin/Chart.lock b/charts/generic-device-plugin/Chart.lock new file mode 100644 index 000000000..7f7b99fc7 --- /dev/null +++ b/charts/generic-device-plugin/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: common + repository: https://bjw-s.github.io/helm-charts + version: 1.4.0 +digest: sha256:4b75202a3971677362052bcee21a023ea42a0c18991800ae62a8890d4655b699 +generated: "2023-04-24T01:07:47.392308-05:00" diff --git a/charts/generic-device-plugin/Chart.yaml b/charts/generic-device-plugin/Chart.yaml new file mode 100644 index 000000000..d4eb6f112 --- /dev/null +++ b/charts/generic-device-plugin/Chart.yaml @@ -0,0 +1,26 @@ +apiVersion: v2 +name: generic-device-plugin +description: The generic-device-plugin enables allocating generic Linux devices, such as serial devices, the FUSE device, or video cameras, to Kubernetes Pods +home: https://charts.gabe565.com/charts/generic-device-plugin/ +type: application +version: 0.0.1 +# renovate datasource=docker depName=ghcr.io/squat/generic-device-plugin +appVersion: latest +kubeVersion: ">=1.22.0-0" +keywords: + - device-plugin +dependencies: + - name: common + repository: https://bjw-s.github.io/helm-charts + version: 1.4.0 +sources: + - https://github.com/squat/generic-device-plugin +annotations: + artifacthub.io/changes: |- + - kind: added + description: Initial release + artifacthub.io/links: |- + - name: App Source + url: https://github.com/squat/generic-device-plugin + - name: Chart Source + url: https://github.com/gabe565/charts/tree/main/charts/generic-device-plugin diff --git a/charts/generic-device-plugin/README.md b/charts/generic-device-plugin/README.md new file mode 100644 index 000000000..23f69ec84 --- /dev/null +++ b/charts/generic-device-plugin/README.md @@ -0,0 +1,174 @@ +# Generic Device Plugin + +![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat) +![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat) +![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat) + +The generic-device-plugin enables allocating generic Linux devices, such as serial devices, the FUSE device, or video cameras, to Kubernetes Pods + +**Homepage:** + +**This chart is not maintained by the upstream project and any issues with the chart should be raised +[here](https://github.com/gabe565/charts/issues/new?assignees=gabe565&labels=bug&template=bug_report.yaml&name=generic-device-plugin&version=0.0.1)** + +## Source Code + +* + +## Requirements + +Kubernetes: `>=1.22.0-0` + +## Dependencies + +| Repository | Name | Version | +|------------|------|---------| +| | common | 1.4.0 | + +## TL;DR + +```console +helm repo add gabe565 https://charts.gabe565.com +helm repo update +helm install generic-device-plugin gabe565/generic-device-plugin +``` + +## Installing the Chart + +To install the chart with the release name `generic-device-plugin` + +```console +helm install generic-device-plugin gabe565/generic-device-plugin +``` + +## Uninstalling the Chart + +To uninstall the `generic-device-plugin` deployment + +```console +helm uninstall generic-device-plugin +``` + +The command removes all the Kubernetes components associated with the chart **including persistent volumes** and deletes the release. + +## Configuration + +Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values. +Other values may be used from the [values.yaml](https://github.com/bjw-s/helm-charts/tree/main/charts/library/common/values.yaml) from the [bjw-s common library](https://github.com/bjw-s/helm-charts/tree/main/charts/library/common). + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. + +```console +helm install generic-device-plugin \ + --set env.TZ="America/New York" \ + gabe565/generic-device-plugin +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. + +```console +helm install generic-device-plugin gabe565/generic-device-plugin -f values.yaml +``` + +## Custom configuration + +### Configuring Devices +Generic Device Plugin will only expose whitelisted devices. +To add a device with this Helm chart, add it to `config.data` in the following format: + +```yaml +config: + data: | + devices: + - +``` + +#### Device Spec +- Multiple paths can be given for each type. Paths can be globs. +- Should be provided in the form: + ```yaml + name: + groups: + - + count: + ``` + +#### Device Definition +- The device definition can be either a path to a device file or a USB device. You cannot define both in the same group. +- For device files, use something like: + ```yaml + paths: + - path: + mountPath: + - path: + mountPath: + ``` + - For example, to expose serial devices with different names: + ```yaml + name: serial + groups: + - paths: + - path: /dev/ttyUSB* + - paths: + - path: /dev/ttyACM* + ``` + - For USB devices, use something like: + ```yaml + usb: + - vendor: "1209" + product: "000F" + ``` + - For example, to expose a CH340 serial converter: + ```yaml + name: ch340 + groups: + - usb: + - vendor: "1a86" + product: "7523" + ``` +- The device flag can specify lists of devices that should be grouped and mounted into a container together as one single meta-device. + - For example, to allocate and mount an audio capture device: + ```yaml + name: capture + groups: + - paths: + - path: /dev/snd/pcmC0D0c + - path: /dev/snd/controlC0 + ``` +- A "count" can be specified to allow a discovered device group to be scheduled multiple times. + - For example, to permit allocation of the FUSE device 10 times: + ```yaml + name: fuse + groups: + - count: 10 + paths: + - path: /dev/fuse + ``` + - Note: if omitted, "count" is assumed to be 1 + +See [values.yaml](./values.yaml) for an example configuration file. + +## Values + +**Important**: When deploying an application Helm chart you can add more values from the bjw-s common library chart [here](https://github.com/bjw-s/helm-charts/tree/main/charts/library/common) + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| config.data | string | See [values.yaml](./values.yaml) | generic-device-plugin config file [[ref]](https://github.com/squat/generic-device-plugin#usage) | +| config.enabled | bool | `true` | Enables the config file ConfigMap | +| controller.type | string | `"daemonset"` | Sets the controller type | +| env | object | See [values.yaml](./values.yaml) | Environment variables [[ref]](https://github.com/squat/generic-device-plugin#usage) | +| env.DOMAIN | string | `"squat.ai"` | The domain to use when declaring devices | +| image.pullPolicy | string | `"Always"` | Image pull policy | +| image.repository | string | `"ghcr.io/squat/generic-device-plugin"` | Image repository | +| image.tag | string | `"latest"` | Image tag | +| persistence.dev | object | See [values.yaml](./values.yaml) | Host path volume bind to the dev dir | +| persistence.device-plugins | object | See [values.yaml](./values.yaml) | Host path volume bind to the Kubelet plugin directory | +| probes.liveness | object | `{"path":"/health","type":"HTTP"}` | Configures liveness probe | +| probes.readiness | object | `{"path":"/health","type":"HTTP"}` | Configures readiness probe | +| probes.startup | object | `{"path":"/health","type":"HTTP"}` | Configures startup probe | +| securityContext.privileged | bool | `true` | Privileged mode is required to access devices | +| service.main | object | See [values.yaml](./values.yaml) | Configures health/metrics service settings for the chart. | + +--- +Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs) diff --git a/charts/generic-device-plugin/README_CONFIG.md.gotmpl b/charts/generic-device-plugin/README_CONFIG.md.gotmpl new file mode 100644 index 000000000..3affe7f98 --- /dev/null +++ b/charts/generic-device-plugin/README_CONFIG.md.gotmpl @@ -0,0 +1,87 @@ +{{- define "custom.chart.name" -}} +Generic Device Plugin +{{- end -}} + +{{- define "custom.custom.configuration.header" -}} +## Custom configuration +{{- end -}} + +{{- define "custom.custom.configuration" -}} +{{ template "custom.custom.configuration.header" . }} + +### Configuring Devices +Generic Device Plugin will only expose whitelisted devices. +To add a device with this Helm chart, add it to `config.data` in the following format: + +```yaml +config: + data: | + devices: + - +``` + +#### Device Spec +- Multiple paths can be given for each type. Paths can be globs. +- Should be provided in the form: + ```yaml + name: + groups: + - + count: + ``` + +#### Device Definition +- The device definition can be either a path to a device file or a USB device. You cannot define both in the same group. +- For device files, use something like: + ```yaml + paths: + - path: + mountPath: + - path: + mountPath: + ``` + - For example, to expose serial devices with different names: + ```yaml + name: serial + groups: + - paths: + - path: /dev/ttyUSB* + - paths: + - path: /dev/ttyACM* + ``` + - For USB devices, use something like: + ```yaml + usb: + - vendor: "1209" + product: "000F" + ``` + - For example, to expose a CH340 serial converter: + ```yaml + name: ch340 + groups: + - usb: + - vendor: "1a86" + product: "7523" + ``` +- The device flag can specify lists of devices that should be grouped and mounted into a container together as one single meta-device. + - For example, to allocate and mount an audio capture device: + ```yaml + name: capture + groups: + - paths: + - path: /dev/snd/pcmC0D0c + - path: /dev/snd/controlC0 + ``` +- A "count" can be specified to allow a discovered device group to be scheduled multiple times. + - For example, to permit allocation of the FUSE device 10 times: + ```yaml + name: fuse + groups: + - count: 10 + paths: + - path: /dev/fuse + ``` + - Note: if omitted, "count" is assumed to be 1 + +See [values.yaml](./values.yaml) for an example configuration file. +{{- end -}} diff --git a/charts/generic-device-plugin/templates/NOTES.txt b/charts/generic-device-plugin/templates/NOTES.txt new file mode 100644 index 000000000..44ecfaa6c --- /dev/null +++ b/charts/generic-device-plugin/templates/NOTES.txt @@ -0,0 +1 @@ +{{- include "bjw-s.common.lib.chart.notes" . -}} diff --git a/charts/generic-device-plugin/templates/common.yaml b/charts/generic-device-plugin/templates/common.yaml new file mode 100644 index 000000000..f2c4fcb60 --- /dev/null +++ b/charts/generic-device-plugin/templates/common.yaml @@ -0,0 +1,35 @@ +{{- define "genericDevicePlugin.config" -}} +{{- with .Values.config }} +{{- if .enabled }} +args: + - --config=/config/config.yaml + +configMaps: + config: + enabled: true + data: + config.yaml: {{ toYaml .data | nindent 8 }} + +persistence: + config: + enabled: true + type: configMap + name: {{ include "bjw-s.common.lib.chart.names.fullname" $ }}-config +{{- end }} +{{- end }} +{{- end -}} +{{- $_ := merge .Values (include "genericDevicePlugin.config" . | fromYaml) -}} + +{{/* Append the hardcoded settings */}} +{{- define "genericDevicePlugin.defaultValues" -}} +env: + LISTEN: :{{ .Values.service.main.ports.http.port }} + + {{- with get .Values.persistence "device-plugins" }} + PLUGIN_DIRECTORY: {{ .mountPath | default .hostPath }} + {{- end }} +{{- end -}} +{{- $_ = merge .Values (include "genericDevicePlugin.defaultValues" . | fromYaml) -}} + +{{/* Render the templates */}} +{{ include "bjw-s.common.loader.all" . }} diff --git a/charts/generic-device-plugin/values.yaml b/charts/generic-device-plugin/values.yaml new file mode 100644 index 000000000..730f2f4f1 --- /dev/null +++ b/charts/generic-device-plugin/values.yaml @@ -0,0 +1,120 @@ +# +# IMPORTANT NOTE +# +# This chart inherits from our common library chart. You can check the default values/options here: +# https://github.com/bjw-s/helm-charts/blob/main/charts/library/common/values.yaml +# + +image: + # -- Image repository + repository: ghcr.io/squat/generic-device-plugin + # -- Image pull policy + pullPolicy: Always + # -- Image tag + tag: latest + +controller: + # -- Sets the controller type + type: daemonset + +securityContext: + # -- Privileged mode is required to access devices + privileged: true + +# -- Environment variables [[ref]](https://github.com/squat/generic-device-plugin#usage) +# @default -- See [values.yaml](./values.yaml) +env: + # -- The domain to use when declaring devices + DOMAIN: squat.ai + +persistence: + # -- Host path volume bind to the Kubelet plugin directory + # @default -- See [values.yaml](./values.yaml) + device-plugins: + enabled: true + type: hostPath + hostPath: /var/lib/kubelet/device-plugins + # -- Host path volume bind to the dev dir + # @default -- See [values.yaml](./values.yaml) + dev: + enabled: true + type: hostPath + hostPath: /dev + +config: + # -- Enables the config file ConfigMap + enabled: true + # -- generic-device-plugin config file [[ref]](https://github.com/squat/generic-device-plugin#usage) + # @default -- See [values.yaml](./values.yaml) + data: | + devices: + - name: serial + groups: + - paths: + - path: /dev/ttyUSB* + - paths: + - path: /dev/ttyACM* + - paths: + - path: /dev/tty.usb* + - paths: + - path: /dev/cu.* + - paths: + - path: /dev/cuaU* + - paths: + - path: /dev/rfcomm* + - name: video + groups: + - paths: + - path: /dev/video0 + - name: fuse + groups: + - count: 10 + paths: + - path: /dev/fuse + - name: audio + groups: + - count: 10 + paths: + - path: /dev/snd + - name: capture + groups: + - paths: + - path: /dev/snd/controlC0 + - path: /dev/snd/pcmC0D0c + - paths: + - path: /dev/snd/controlC1 + mountPath: /dev/snd/controlC0 + - path: /dev/snd/pcmC1D0c + mountPath: /dev/snd/pcmC0D0c + - paths: + - path: /dev/snd/controlC2 + mountPath: /dev/snd/controlC0 + - path: /dev/snd/pcmC2D0c + mountPath: /dev/snd/pcmC0D0c + - paths: + - path: /dev/snd/controlC3 + mountPath: /dev/snd/controlC0 + - path: /dev/snd/pcmC3D0c + mountPath: /dev/snd/pcmC0D0c + +service: + # -- Configures health/metrics service settings for the chart. + # @default -- See [values.yaml](./values.yaml) + main: + ports: + http: + port: 8080 + +probes: + # -- Configures liveness probe + liveness: + type: HTTP + path: /health + # -- Configures readiness probe + readiness: + type: HTTP + path: /health + # -- Configures startup probe + startup: + type: HTTP + path: /health