Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add helm chart #66

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/cd-helm-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release Helm Chart
concurrency: chart_releaser

on:
push:
branches:
- main
paths:
- 'charts/generic-device-plugin/**'

jobs:
release:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Fetch history
run: git fetch --prune --unshallow

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"

- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.14.3

- name: Run chart-releaser for generic-device-plugin
uses: helm/[email protected]
env:
CR_GENERATE_RELEASE_NOTES: true
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
38 changes: 38 additions & 0 deletions .github/workflows/ci-helm-lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint Chart

on:
pull_request:
paths:
- 'charts/generic-device-plugin/**'

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: "0"

- name: Install Helm
uses: azure/setup-helm@v4

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Run chart-testing (lint)
id: lint
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
23 changes: 23 additions & 0 deletions charts/generic-device-plugin/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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/
28 changes: 28 additions & 0 deletions charts/generic-device-plugin/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v2
name: generic-device-plugin
description: A Helm chart for deploying the generic-device-plugin on Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.0"

maintainers:
- name: squat
url: https://github.com/squat
50 changes: 50 additions & 0 deletions charts/generic-device-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# generic-device-plugin

![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)

A Helm chart for deploying the generic-device-plugin on Kubernetes.

## Tips

Ensure that this is deployed into the `kube-system` namespace.

### Installing directly from the git repo

```bash
# clone the repo
git clone https://github.com/squat/generic-device-plugin

# change to the chart directory
cd charts/generic-device-plugin

# install the helm chart in the kube-system namespace
helm install -n kube-system generic-device-plugin .
```

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| squat | | <https://github.com/squat> |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| deployPodMonitor | bool | `true` | deploy the podMonitor (requires PodMonitor CRD to be installed) |
| fullnameOverride | string | `""` | override the fullname of the chart resources |
| image.pullPolicy | string | `"Always"` | image pullPolicy is set to always because tag is set to latest |
| image.repository | string | `"squat/generic-device-plugin"` | container image repo |
| image.tag | string | `"latest"` | Overrides the image tag whose default is the chart appVersion. |
| nameOverride | string | `""` | override the name of the chart resources |
| podAnnotations | object | `{}` | additional annotations for the generic-device-plugin pod |
| podLabels | object | `{}` | additional labels for the generic-device-plugin pod |
| resources | object | `{"limits":{"cpu":"50m","memory":"20Mi"},"requests":{"cpu":"50m","memory":"10Mi"}}` | resource requests and limits for the generic-device-plugin pod |
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.automount | bool | `true` | Automatically mount a ServiceAccount's API credentials? |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
| 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 |
| tolerations | list | `[{"effect":"NoExecute","operator":"Exists"},{"effect":"NoSchedule","operator":"Exists"}]` | tolerations of kubernetes taints |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)
62 changes: 62 additions & 0 deletions charts/generic-device-plugin/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "generic-device-plugin.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "generic-device-plugin.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "generic-device-plugin.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "generic-device-plugin.labels" -}}
helm.sh/chart: {{ include "generic-device-plugin.chart" . }}
{{ include "generic-device-plugin.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "generic-device-plugin.selectorLabels" -}}
app.kubernetes.io/name: {{ include "generic-device-plugin.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "generic-device-plugin.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "generic-device-plugin.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
115 changes: 115 additions & 0 deletions charts/generic-device-plugin/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "generic-device-plugin.fullname" . }}
namespace: kube-system
labels:
app.kubernetes.io/name: generic-device-plugin
{{- include "generic-device-plugin.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: generic-device-plugin
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app.kubernetes.io/name: generic-device-plugin
{{- include "generic-device-plugin.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "generic-device-plugin.serviceAccountName" . }}
priorityClassName: system-node-critical
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: generic-device-plugin
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- --device
- |
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*
- --device
- |
name: video
groups:
- paths:
- path: /dev/video0
- --device
- |
name: fuse
groups:
- count: 10
paths:
- path: /dev/fuse
- --device
- |
name: audio
groups:
- count: 10
paths:
- path: /dev/snd
- --device
- |
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
resources:
{{- toYaml .Values.resources | nindent 12 }}
ports:
- containerPort: 8080
name: http
securityContext:
privileged: true
volumeMounts:
- name: device-plugin
mountPath: /var/lib/kubelet/device-plugins
- name: dev
mountPath: /dev
volumes:
- name: device-plugin
hostPath:
path: /var/lib/kubelet/device-plugins
- name: dev
hostPath:
path: /dev
updateStrategy:
type: RollingUpdate
18 changes: 18 additions & 0 deletions charts/generic-device-plugin/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.deployPodMonitor }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
labels:
app.kubernetes.io/name: generic-device-plugin
{{- include "generic-device-plugin.labels" . | nindent 4 }}
name: {{ include "generic-device-plugin.fullname" . }}
namespace: kube-system
spec:
podMetricsEndpoints:
- interval: 15s
port: http
path: /metrics
selector:
matchLabels:
app.kubernetes.io/name: generic-device-plugin
{{- end }}
13 changes: 13 additions & 0 deletions charts/generic-device-plugin/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "generic-device-plugin.serviceAccountName" . }}
labels:
{{- include "generic-device-plugin.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
Loading