mirror of
https://github.com/k8s-at-home/charts.git
synced 2025-01-23 23:49:12 +00:00
[smarter-device-manager] New chart (#532)
This commit is contained in:
parent
a32e94cfca
commit
1c7d6d403e
24
charts/smarter-device-manager/.helmignore
Normal file
24
charts/smarter-device-manager/.helmignore
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# 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
|
||||||
|
*~
|
||||||
|
# Various IDEs
|
||||||
|
.project
|
||||||
|
.idea/
|
||||||
|
*.tmproj
|
||||||
|
.vscode/
|
||||||
|
# OWNERS file for Kubernetes
|
||||||
|
OWNERS
|
22
charts/smarter-device-manager/Chart.yaml
Normal file
22
charts/smarter-device-manager/Chart.yaml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: smarter-device-manager
|
||||||
|
version: 1.0.0
|
||||||
|
appVersion: 1.1.2
|
||||||
|
description: Manage hardware resource allocation without a need for privileged containers
|
||||||
|
keywords:
|
||||||
|
- kubernetes
|
||||||
|
- cluster
|
||||||
|
- hardware
|
||||||
|
home: https://gitlab.com/arm-research/smarter/smarter-device-manager/
|
||||||
|
sources:
|
||||||
|
- https://gitlab.com/arm-research/smarter/smarter-device-manager/
|
||||||
|
- https://github.com/k8s-at-home/charts
|
||||||
|
dependencies:
|
||||||
|
- name: common
|
||||||
|
repository: https://k8s-at-home.com/charts/
|
||||||
|
version: 2.4.0
|
||||||
|
maintainers:
|
||||||
|
- name: bjw-s
|
||||||
|
email: me@bjw-s.dev
|
||||||
|
- name: lazyoldbear
|
||||||
|
email: 19270832+lazyoldbear@users.noreply.github.com
|
111
charts/smarter-device-manager/README.md
Normal file
111
charts/smarter-device-manager/README.md
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
# smarter device manager
|
||||||
|
|
||||||
|
This is a helm chart for [smarter-device-manager](https://gitlab.com/arm-research/smarter/smarter-device-manager/)
|
||||||
|
([see also](https://community.arm.com/developer/research/b/articles/posts/a-smarter-device-manager-for-kubernetes-on-the-edge)).
|
||||||
|
|
||||||
|
This tool discovers host hardware resources and manages their provisioning for the pods, decoupling host paths from them, and ensuring that pods don't compete for the same piece of hardware.
|
||||||
|
|
||||||
|
Typical use cases are Zigbee/Zwave USB dongles for other charts available in this repository (Zigbee2MQTT, ZwaveJS2MQTT).
|
||||||
|
|
||||||
|
**This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/k8s-at-home/charts/issues/new/choose)**
|
||||||
|
|
||||||
|
## TL;DR;
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ helm repo add k8s-at-home https://k8s-at-home.com/charts/
|
||||||
|
$ helm install k8s-at-home/smarter-device-manager
|
||||||
|
```
|
||||||
|
|
||||||
|
## Installing the Chart
|
||||||
|
|
||||||
|
To install the chart with the release name `my-release`:
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm install --name my-release k8s-at-home/smarter-device-manager
|
||||||
|
```
|
||||||
|
|
||||||
|
Please consider overriding the default configuration through `values.yaml` file.
|
||||||
|
For example:
|
||||||
|
```yaml
|
||||||
|
config:
|
||||||
|
- devicematch: ^snd$
|
||||||
|
nummaxdevices: 20
|
||||||
|
- devicematch: ^rtc0$
|
||||||
|
nummaxdevices: 20
|
||||||
|
- devicematch: ^video[0-9]*$
|
||||||
|
nummaxdevices: 20
|
||||||
|
- devicematch: ^ttyACM[0-9]*$
|
||||||
|
nummaxdevices: 1
|
||||||
|
```
|
||||||
|
The above configuration allows up to twenty pods to make use of `/dev/snd`, `/dev/rtc0` and each of `/dev/video[0-9]*` devices.
|
||||||
|
Only one pod at a time can use any of the discovered host `/dev/ttyACM[0-9]*` devices. This means that if a pod has reserved a dongle at `/dev/ttyACM0`, another pod requesting the same device will stay pending.
|
||||||
|
|
||||||
|
Once the devices are discovered, they will be added as allocatable resources to the nodes:
|
||||||
|
```
|
||||||
|
$ kubectl describe nodes
|
||||||
|
...
|
||||||
|
Capacity:
|
||||||
|
cpu: 4
|
||||||
|
memory: 16104560Ki
|
||||||
|
pods: 110
|
||||||
|
smarter-devices/gpiochip0: 0
|
||||||
|
smarter-devices/i2c-0: 0
|
||||||
|
smarter-devices/snd: 20
|
||||||
|
smarter-devices/ttyUSB-Z-Stick-Gen5: 1
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Important limitation
|
||||||
|
|
||||||
|
Please note that only the root of the host `/dev` directory is considered for discovery. _Therefore, `by-id` paths will not work and some `udev` rules may be necessary._
|
||||||
|
|
||||||
|
### Resource allocation
|
||||||
|
|
||||||
|
The hardware is requested by pods through `resources`, e.g.:
|
||||||
|
```yaml
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
smarter-devices/ttyUSB-Conbee-2: 1
|
||||||
|
requests:
|
||||||
|
smarter-devices/ttyUSB-Conbee-2: 1
|
||||||
|
```
|
||||||
|
|
||||||
|
In this case host device `/dev/ttyUSB-Conbee-2` will be given at the same path, and the pod will only be created when this device is available.
|
||||||
|
|
||||||
|
## Uninstalling the Chart
|
||||||
|
|
||||||
|
To uninstall/delete the `my-release` deployment:
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm delete my-release --purge
|
||||||
|
```
|
||||||
|
|
||||||
|
The command removes all the Kubernetes components associated with the chart and deletes the release.
|
||||||
|
|
||||||
|
Read through the charts [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/smarter-device-manager/values.yaml)
|
||||||
|
file. It has several commented out suggested values.
|
||||||
|
Additionally you can take a look at the common library [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/common/values.yaml) for more (advanced) configuration options.
|
||||||
|
|
||||||
|
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
|
||||||
|
```console
|
||||||
|
helm install my-release \
|
||||||
|
--set image.pullPolicy="Always" \
|
||||||
|
k8s-at-home/smarter-device-manager
|
||||||
|
```
|
||||||
|
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the
|
||||||
|
chart. For example,
|
||||||
|
```console
|
||||||
|
helm install my-release k8s-at-home/smarter-device-manager --values values.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
image:
|
||||||
|
tag: ...
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Upgrading an existing Release to a new major version
|
||||||
|
|
||||||
|
A major chart version change (like 4.0.1 -> 5.0.0) indicates that there is an incompatible breaking change potentially needing manual actions.
|
77
charts/smarter-device-manager/templates/common.yaml
Normal file
77
charts/smarter-device-manager/templates/common.yaml
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
{{/* Make sure all variables are set properly */}}
|
||||||
|
{{- include "common.values.setup" . }}
|
||||||
|
|
||||||
|
{{/* Host paths */}}
|
||||||
|
{{- define "sdm.dev.volume" -}}
|
||||||
|
name: host-dev
|
||||||
|
hostPath:
|
||||||
|
path: {{ .Values.devPath | default "/dev" }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- define "sdm.sys.volume" -}}
|
||||||
|
name: host-sys
|
||||||
|
hostPath:
|
||||||
|
path: {{ .Values.sysPath | default "/sys" }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- define "sdm.device-plugins.volume" -}}
|
||||||
|
name: host-device-plugins
|
||||||
|
hostPath:
|
||||||
|
path: {{ .Values.devicePluginPath | default "/var/lib/kubelet/device-plugins" }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "sdm.dev.volumeMount" -}}
|
||||||
|
name: host-dev
|
||||||
|
mountPath: /dev
|
||||||
|
{{- end -}}
|
||||||
|
{{- define "sdm.sys.volumeMount" -}}
|
||||||
|
name: host-sys
|
||||||
|
mountPath: /sys
|
||||||
|
{{- end -}}
|
||||||
|
{{- define "sdm.device-plugins.volumeMount" -}}
|
||||||
|
name: host-device-plugins
|
||||||
|
mountPath: /var/lib/kubelet/device-plugins
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/* Append host paths and the configMap to the additionalVolumes and additionalVolumeMounts */}}
|
||||||
|
{{- define "sdm.configmap.volume" -}}
|
||||||
|
name: configuration
|
||||||
|
configMap:
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- $additionalVolumes := .Values.additionalVolumes -}}
|
||||||
|
{{- $volume := include "sdm.dev.volume" . | fromYaml -}}
|
||||||
|
{{- $additionalVolumes := append $additionalVolumes $volume -}}
|
||||||
|
{{- $volume := include "sdm.sys.volume" . | fromYaml -}}
|
||||||
|
{{- $additionalVolumes := append $additionalVolumes $volume -}}
|
||||||
|
{{- $volume := include "sdm.device-plugins.volume" . | fromYaml -}}
|
||||||
|
{{- $additionalVolumes := append $additionalVolumes $volume -}}
|
||||||
|
{{- $volume := include "sdm.configmap.volume" . | fromYaml -}}
|
||||||
|
{{- $additionalVolumes := append $additionalVolumes $volume -}}
|
||||||
|
{{- $_ := set .Values "additionalVolumes" (deepCopy $additionalVolumes) -}}
|
||||||
|
|
||||||
|
{{- define "sdm.configmap.volumeMount" -}}
|
||||||
|
name: configuration
|
||||||
|
mountPath: /root/config/conf.yaml
|
||||||
|
subPath: conf.yaml
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- $additionalVolumeMounts := .Values.additionalVolumeMounts -}}
|
||||||
|
{{- $volumeMount := include "sdm.dev.volumeMount" . | fromYaml -}}
|
||||||
|
{{- $additionalVolumeMounts := append $additionalVolumeMounts $volumeMount -}}
|
||||||
|
{{- $volumeMount := include "sdm.sys.volumeMount" . | fromYaml -}}
|
||||||
|
{{- $additionalVolumeMounts := append $additionalVolumeMounts $volumeMount -}}
|
||||||
|
{{- $volumeMount := include "sdm.device-plugins.volumeMount" . | fromYaml -}}
|
||||||
|
{{- $additionalVolumeMounts := append $additionalVolumeMounts $volumeMount -}}
|
||||||
|
{{- $volumeMount := include "sdm.configmap.volumeMount" . | fromYaml -}}
|
||||||
|
{{- $additionalVolumeMounts := append $additionalVolumeMounts $volumeMount -}}
|
||||||
|
{{- $_ := set .Values "additionalVolumeMounts" (deepCopy $additionalVolumeMounts) -}}
|
||||||
|
|
||||||
|
{{/* DaemonSet controller, disabling defaults */}}
|
||||||
|
{{- $_ := set .Values "controllerType" "daemonset" }}
|
||||||
|
{{- $_ := set .Values.probes.liveness "enabled" false }}
|
||||||
|
{{- $_ := set .Values.probes.readiness "enabled" false }}
|
||||||
|
{{- $_ := set .Values.probes.startup "enabled" false }}
|
||||||
|
{{- $_ := set .Values.service "enabled" false }}
|
||||||
|
|
||||||
|
{{/* Render the templates */}}
|
||||||
|
{{ include "common.all" . }}
|
38
charts/smarter-device-manager/templates/configmap.yaml
Normal file
38
charts/smarter-device-manager/templates/configmap.yaml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
labels:
|
||||||
|
{{- include "common.labels" . | nindent 4 }}
|
||||||
|
data:
|
||||||
|
conf.yaml: |
|
||||||
|
{{- if not .Values.config }}
|
||||||
|
- devicematch: ^snd$
|
||||||
|
nummaxdevices: 20
|
||||||
|
#- devicematch: ^gpiomem$
|
||||||
|
# nummaxdevices: 40
|
||||||
|
#- devicematch: ^gpiochip[0-9]*$
|
||||||
|
# nummaxdevices: 20
|
||||||
|
#- devicematch: ^hci[0-9]*$
|
||||||
|
# nummaxdevices: 1
|
||||||
|
#- devicematch: ^i2c-[0-9]*$
|
||||||
|
# nummaxdevices: 1
|
||||||
|
#- devicematch: ^rtc0$
|
||||||
|
# nummaxdevices: 20
|
||||||
|
#- devicematch: ^video[0-9]*$
|
||||||
|
# nummaxdevices: 20
|
||||||
|
#- devicematch: ^vchiq$
|
||||||
|
# nummaxdevices: 20
|
||||||
|
#- devicematch: ^vcsm.*$
|
||||||
|
# nummaxdevices: 20
|
||||||
|
- devicematch: ^ttyUSB.*$
|
||||||
|
nummaxdevices: 1
|
||||||
|
#- devicematch: ^ttyACM[0-9]*$
|
||||||
|
# nummaxdevices: 1
|
||||||
|
#- devicematch: ^ttyTHS[0-9]*$
|
||||||
|
# nummaxdevices: 1
|
||||||
|
#- devicematch: ^ttyS[0-9]*$
|
||||||
|
# nummaxdevices: 1
|
||||||
|
{{- else }}
|
||||||
|
{{- toYaml .Values.config | nindent 4 }}
|
||||||
|
{{- end }}
|
32
charts/smarter-device-manager/values.yaml
Normal file
32
charts/smarter-device-manager/values.yaml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
image:
|
||||||
|
repository: registry.gitlab.com/arm-research/smarter/smarter-device-manager
|
||||||
|
tag: v1.1.2
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
# Override default configuration
|
||||||
|
# config:
|
||||||
|
# - devicematch: ^snd$
|
||||||
|
# nummaxdevices: 20
|
||||||
|
# - devicematch: ^ttyUSB.*$
|
||||||
|
# nummaxdevices: 1
|
||||||
|
|
||||||
|
hostNetwork: true
|
||||||
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
|
|
||||||
|
devicePluginPath: "/var/lib/kubelet/device-plugins"
|
||||||
|
# devPath: "/special-dev/"
|
||||||
|
# sysPath: "/special-sys/"
|
||||||
|
|
||||||
|
# Setting priority class is not necessary, but is recommended.
|
||||||
|
# Ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
|
||||||
|
priorityClassName: system-node-critical
|
||||||
|
|
||||||
|
|
||||||
|
securityContext:
|
||||||
|
capabilities:
|
||||||
|
drop:
|
||||||
|
- ALL
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
# readOnlyRootFilesystem: true
|
||||||
|
# runAsNonRoot: true
|
||||||
|
# runAsUser: 1000
|
Loading…
Reference in New Issue
Block a user