From 53191f1d6853e90a7086a5718470e7359e883d6b Mon Sep 17 00:00:00 2001 From: alexlebens Date: Sat, 12 Oct 2024 23:18:07 -0500 Subject: [PATCH] add generic device plugin --- charts/generic-device-plugin/Chart.yaml | 18 +++++ charts/generic-device-plugin/README.md | 16 ++++ .../templates/common.yaml | 76 +++++++++++++++++++ charts/generic-device-plugin/values.yaml | 74 ++++++++++++++++++ 4 files changed, 184 insertions(+) create mode 100644 charts/generic-device-plugin/Chart.yaml create mode 100644 charts/generic-device-plugin/README.md create mode 100644 charts/generic-device-plugin/templates/common.yaml create mode 100644 charts/generic-device-plugin/values.yaml diff --git a/charts/generic-device-plugin/Chart.yaml b/charts/generic-device-plugin/Chart.yaml new file mode 100644 index 0000000..adcbe4e --- /dev/null +++ b/charts/generic-device-plugin/Chart.yaml @@ -0,0 +1,18 @@ +apiVersion: v2 +name: generic-device-plugin +version: 0.1.0 +description: Generic Device Plugin +keywords: + - generic-device-plugin + - device + - plugin +sources: + - https://github.com/squat/generic-device-plugin + - https://github.com/bjw-s/helm-charts/tree/main/charts/library/common +maintainers: + - name: alexlebens +dependencies: + - name: common + repository: https://bjw-s.github.io/helm-charts/ + version: 3.5.1 +appVersion: 0.1.0 diff --git a/charts/generic-device-plugin/README.md b/charts/generic-device-plugin/README.md new file mode 100644 index 0000000..8094734 --- /dev/null +++ b/charts/generic-device-plugin/README.md @@ -0,0 +1,16 @@ +## Introduction + +[Generic Device Plugin](https://github.com/squat/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. + +This chart bootstraps a [Generic Device Plugin](https://github.com/squat/generic-device-plugin) daemonset on a [Kubernetes](https://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes +- Helm + +## Parameters + +See the [values files](values.yaml). diff --git a/charts/generic-device-plugin/templates/common.yaml b/charts/generic-device-plugin/templates/common.yaml new file mode 100644 index 0000000..dc6740d --- /dev/null +++ b/charts/generic-device-plugin/templates/common.yaml @@ -0,0 +1,76 @@ +{{- include "bjw-s.common.loader.init" . }} + +{{- define "genericDevicePlugin.hardcodedValues" -}} +{{ if not .Values.global.nameOverride }} +global: + nameOverride: {{ .Values.name }} +{{ end }} +controllers: + main: + type: daemonset + strategy: RollingUpdate + containers: + main: + image: + repository: {{ .Values.image.repository }} + tag: {{ .Values.image.tag }} + pullPolicy: {{ .Values.image.pullPolicy }} + args: + - --config=/config/config.yaml + env: + - name: LISTEN + value: {{ .Values.service.listenPort }} + - name: PLUGIN_DIRECTORY + value: /var/lib/kubelet/device-plugins + - name: DOMAIN + value: {{ .Values.deviceDomain }} + probes: + liveness: + type: HTTP + path: /health + readiness: + type: HTTP + path: /health + startup: + type: HTTP + path: /health + securityContext: + privileged: True +configMaps: + config: + enabled: {{ .Values.config.enabled }} + data: + config.yaml: {{ toYaml .Values.config.data | nindent 8 }} +service: + main: + controller: main + ports: + http: + port: {{ .Values.service.listenPort }} +persistence: + config: + enabled: true + type: configMap + name: {{ .Values.name }}-config + device-plugins: + enabled: true + type: hostPath + hostPath: /var/lib/kubelet/device-plugins + dev: + enabled: true + type: hostPath + hostPath: /dev +serviceMonitor: + main: + serviceName: generic-device-plugin + endpoints: + - port: http + scheme: http + path: /metrics + interval: 30s + scrapeTimeout: 10s +{{- end -}} +{{- $_ := mergeOverwrite .Values (include "genericDevicePlugin.hardcodedValues" . | fromYaml) -}} + +{{/* Render the templates */}} +{{ include "bjw-s.common.loader.generate" . }} diff --git a/charts/generic-device-plugin/values.yaml b/charts/generic-device-plugin/values.yaml new file mode 100644 index 0000000..60c5ce3 --- /dev/null +++ b/charts/generic-device-plugin/values.yaml @@ -0,0 +1,74 @@ +name: generic-device-plugin + +image: + repository: ghcr.io/squat/generic-device-plugin + pullPolicy: Always + tag: latest + +deviceDomain: squat.ai + +service: + listenPort: 8080 + +resources: + limit: + cpu: 100m + memory: 20Mi + requests: + cpu: 50m + memory: 10Mi + +config: + 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