Skip to content

Commit 8b7ebcb

Browse files
jessebotsquat
authored andcommitted
feat: add a Helm chart for the generic-device-plugin daemonset and podmonitor resources
- add chart release if desired - allow disabling of the pod monitor, and install the CRD for the ci testing add some tips for installing directly
1 parent e11f4bc commit 8b7ebcb

9 files changed

Lines changed: 399 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release Helm Chart
2+
concurrency: chart_releaser
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'charts/generic-device-plugin/**'
10+
11+
jobs:
12+
release:
13+
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
14+
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
15+
permissions:
16+
contents: write
17+
runs-on: ubuntu-22.04
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Fetch history
23+
run: git fetch --prune --unshallow
24+
25+
- name: Configure Git
26+
run: |
27+
git config user.name "$GITHUB_ACTOR"
28+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
29+
30+
- name: Set up Helm
31+
uses: azure/setup-helm@v3.5
32+
with:
33+
version: v3.14.3
34+
35+
- name: Run chart-releaser for generic-device-plugin
36+
uses: helm/chart-releaser-action@v1.6.0
37+
env:
38+
CR_GENERATE_RELEASE_NOTES: true
39+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: v2
2+
name: generic-device-plugin
3+
description: A Helm chart for deploying the generic-device-plugin on Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "0.1.0"
25+
26+
maintainers:
27+
- name: squat
28+
url: https://github.com/squat
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# generic-device-plugin
2+
3+
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
4+
5+
A Helm chart for deploying the generic-device-plugin on Kubernetes.
6+
7+
## Tips
8+
9+
Ensure that this is deployed into the `kube-system` namespace.
10+
11+
### Installing directly from the git repo
12+
13+
```bash
14+
# clone the repo
15+
git clone https://github.com/squat/generic-device-plugin
16+
17+
# change to the chart directory
18+
cd charts/generic-device-plugin
19+
20+
# install the helm chart in the kube-system namespace
21+
helm install -n kube-system generic-device-plugin .
22+
```
23+
24+
## Maintainers
25+
26+
| Name | Email | Url |
27+
| ---- | ------ | --- |
28+
| squat | | <https://github.com/squat> |
29+
30+
## Values
31+
32+
| Key | Type | Default | Description |
33+
|-----|------|---------|-------------|
34+
| deployPodMonitor | bool | `true` | deploy the podMonitor (requires PodMonitor CRD to be installed) |
35+
| fullnameOverride | string | `""` | override the fullname of the chart resources |
36+
| image.pullPolicy | string | `"Always"` | image pullPolicy is set to always because tag is set to latest |
37+
| image.repository | string | `"squat/generic-device-plugin"` | container image repo |
38+
| image.tag | string | `"latest"` | Overrides the image tag whose default is the chart appVersion. |
39+
| nameOverride | string | `""` | override the name of the chart resources |
40+
| podAnnotations | object | `{}` | additional annotations for the generic-device-plugin pod |
41+
| podLabels | object | `{}` | additional labels for the generic-device-plugin pod |
42+
| resources | object | `{"limits":{"cpu":"50m","memory":"20Mi"},"requests":{"cpu":"50m","memory":"10Mi"}}` | resource requests and limits for the generic-device-plugin pod |
43+
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
44+
| serviceAccount.automount | bool | `true` | Automatically mount a ServiceAccount's API credentials? |
45+
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
46+
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
47+
| tolerations | list | `[{"effect":"NoExecute","operator":"Exists"},{"effect":"NoSchedule","operator":"Exists"}]` | tolerations of kubernetes taints |
48+
49+
----------------------------------------------
50+
Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "generic-device-plugin.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "generic-device-plugin.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "generic-device-plugin.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "generic-device-plugin.labels" -}}
37+
helm.sh/chart: {{ include "generic-device-plugin.chart" . }}
38+
{{ include "generic-device-plugin.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "generic-device-plugin.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "generic-device-plugin.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "generic-device-plugin.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "generic-device-plugin.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: {{ include "generic-device-plugin.fullname" . }}
5+
namespace: kube-system
6+
labels:
7+
app.kubernetes.io/name: generic-device-plugin
8+
{{- include "generic-device-plugin.labels" . | nindent 4 }}
9+
spec:
10+
selector:
11+
matchLabels:
12+
app.kubernetes.io/name: generic-device-plugin
13+
template:
14+
metadata:
15+
{{- with .Values.podAnnotations }}
16+
annotations:
17+
{{- toYaml . | nindent 8 }}
18+
{{- end }}
19+
labels:
20+
app.kubernetes.io/name: generic-device-plugin
21+
{{- include "generic-device-plugin.labels" . | nindent 8 }}
22+
{{- with .Values.podLabels }}
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
spec:
26+
serviceAccountName: {{ include "generic-device-plugin.serviceAccountName" . }}
27+
priorityClassName: system-node-critical
28+
{{- with .Values.tolerations }}
29+
tolerations:
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
containers:
33+
- name: generic-device-plugin
34+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
35+
imagePullPolicy: {{ .Values.image.pullPolicy }}
36+
args:
37+
- --device
38+
- |
39+
name: serial
40+
groups:
41+
- paths:
42+
- path: /dev/ttyUSB*
43+
- paths:
44+
- path: /dev/ttyACM*
45+
- paths:
46+
- path: /dev/tty.usb*
47+
- paths:
48+
- path: /dev/cu.*
49+
- paths:
50+
- path: /dev/cuaU*
51+
- paths:
52+
- path: /dev/rfcomm*
53+
- --device
54+
- |
55+
name: video
56+
groups:
57+
- paths:
58+
- path: /dev/video0
59+
- --device
60+
- |
61+
name: fuse
62+
groups:
63+
- count: 10
64+
paths:
65+
- path: /dev/fuse
66+
- --device
67+
- |
68+
name: audio
69+
groups:
70+
- count: 10
71+
paths:
72+
- path: /dev/snd
73+
- --device
74+
- |
75+
name: capture
76+
groups:
77+
- paths:
78+
- path: /dev/snd/controlC0
79+
- path: /dev/snd/pcmC0D0c
80+
- paths:
81+
- path: /dev/snd/controlC1
82+
mountPath: /dev/snd/controlC0
83+
- path: /dev/snd/pcmC1D0c
84+
mountPath: /dev/snd/pcmC0D0c
85+
- paths:
86+
- path: /dev/snd/controlC2
87+
mountPath: /dev/snd/controlC0
88+
- path: /dev/snd/pcmC2D0c
89+
mountPath: /dev/snd/pcmC0D0c
90+
- paths:
91+
- path: /dev/snd/controlC3
92+
mountPath: /dev/snd/controlC0
93+
- path: /dev/snd/pcmC3D0c
94+
mountPath: /dev/snd/pcmC0D0c
95+
resources:
96+
{{- toYaml .Values.resources | nindent 12 }}
97+
ports:
98+
- containerPort: 8080
99+
name: http
100+
securityContext:
101+
privileged: true
102+
volumeMounts:
103+
- name: device-plugin
104+
mountPath: /var/lib/kubelet/device-plugins
105+
- name: dev
106+
mountPath: /dev
107+
volumes:
108+
- name: device-plugin
109+
hostPath:
110+
path: /var/lib/kubelet/device-plugins
111+
- name: dev
112+
hostPath:
113+
path: /dev
114+
updateStrategy:
115+
type: RollingUpdate
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if .Values.deployPodMonitor }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: PodMonitor
4+
metadata:
5+
labels:
6+
app.kubernetes.io/name: generic-device-plugin
7+
{{- include "generic-device-plugin.labels" . | nindent 4 }}
8+
name: {{ include "generic-device-plugin.fullname" . }}
9+
namespace: kube-system
10+
spec:
11+
podMetricsEndpoints:
12+
- interval: 15s
13+
port: http
14+
path: /metrics
15+
selector:
16+
matchLabels:
17+
app.kubernetes.io/name: generic-device-plugin
18+
{{- end }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "generic-device-plugin.serviceAccountName" . }}
6+
labels:
7+
{{- include "generic-device-plugin.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13+
{{- end }}

0 commit comments

Comments
 (0)