Skip to content

Commit f3904d7

Browse files
authored
Merge pull request #2 from DiamondLightSource/add-helm
Add Helm charts, multi-arch containers, and docs
2 parents 92a70fa + c77f0d7 commit f3904d7

27 files changed

+744
-30
lines changed

.github/workflows/_container.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ jobs:
4343
load: true
4444
tags: test-${{ matrix.image-name }}
4545

46+
- name: Set up QEMU
47+
uses: docker/setup-qemu-action@v3
48+
4649
- name: Create tags for publishing image
4750
id: meta
4851
uses: docker/metadata-action@v5
@@ -60,6 +63,7 @@ jobs:
6063
with:
6164
context: .
6265
file: ${{ matrix.containerfile }}
66+
platforms: linux/amd64,linux/arm64
6367
push: true
6468
tags: ${{ steps.meta.outputs.tags }}
6569
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/_helm.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Package helm charts
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
HELM_VERSION_TO_INSTALL: 3.17.1
8+
9+
jobs:
10+
package-helm-charts:
11+
name: Package and Push Helm Chart
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Install helm
20+
uses: Azure/setup-helm@v3
21+
with:
22+
version: ${{ env.HELM_VERSION_TO_INSTALL }}
23+
24+
# Check that alpha/beta versions have the form X.Y.Z-alpha.A required by Helm.
25+
- name: Check helm version tag
26+
if: ${{ github.ref_type == 'tag' }}
27+
env:
28+
VERSION: "${{ github.ref_name }}"
29+
run: |
30+
if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+((-alpha|-beta|-rc)\.[0-9]+)?$ ]]; then
31+
echo "Valid version format: '${VERSION}'"
32+
else
33+
echo "Invalid version: '${VERSION}'. Expected: 'X.Y.Z' or 'X.Y.Z-beta.1' or 'X.Y.Z-alpha.1'"
34+
exit 1
35+
fi
36+
37+
- name: Package helm charts
38+
env:
39+
VERSION: "${{ github.ref_type == 'tag' && github.ref_name || '0.0.0' }}"
40+
run: |
41+
set -xe
42+
43+
mkdir -p charts
44+
for i in $(find Charts -type d -maxdepth 1 -mindepth 1); do
45+
echo "Packaging chart: ${i}"
46+
helm package -u --app-version ${VERSION} --version ${VERSION} ${i}
47+
mv $(basename ${i})-*.tgz charts/
48+
done
49+
50+
- name: Push tagged helm chart to registry
51+
if: ${{ github.ref_type == 'tag' }}
52+
run: |
53+
set -x
54+
55+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io/${{ github.repository_owner }} --username ${{ github.repository_owner }} --password-stdin
56+
REGISTRY=oci://ghcr.io/${{github.repository_owner }}/charts
57+
for i in charts/*.tgz; do
58+
helm push "${i}" ${REGISTRY,,}
59+
done

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ jobs:
2525
contents: read
2626
packages: write
2727

28+
helm:
29+
uses: ./.github/workflows/_helm.yml
30+
permissions:
31+
contents: read
32+
packages: write
33+
2834
docs:
2935
uses: ./.github/workflows/_docs.yml
3036
permissions:

.gitignore

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Binaries
2-
agent
3-
manager
4-
plugin
2+
/agent
3+
/manager
4+
/plugin
55
*.exe
66

77
# Test output
@@ -18,4 +18,8 @@ _build/
1818
.DS_Store
1919

2020
# Local settings
21-
.claude/settings.local.json
21+
.claude/settings.local.json
22+
23+
# helm outputs
24+
**/charts
25+
**/Chart.lock
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/

Charts/dra-usbip-driver/Chart.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v2
2+
name: dra-usbip-driver
3+
description: >-
4+
Installs the DRA USB/IP driver, which allows sharing USB devices that are exposed by the DRA USB/IP Agent.
5+
The driver consists of two components: a manager that runs as a Deployment and a plugin that runs as a DaemonSet.
6+
The manager polls the agents for USB device information and creates ResourceSlice objects in the cluster.
7+
8+
type: application
9+
version: 0.1.1
10+
# NOTE: the CI replaces appVersion with the current git tag.
11+
appVersion: "0.1.1"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
dra-usbip-driver has been installed.
2+
3+
Manager: {{ include "dra-usbip-driver.fullname" . }}-manager (Deployment)
4+
Plugin: {{ include "dra-usbip-driver.fullname" . }}-plugin (DaemonSet)
5+
6+
{{- if .Values.manager.agents }}
7+
Configured agents:
8+
{{- range .Values.manager.agents }}
9+
- {{ . }}
10+
{{- end }}
11+
{{- else }}
12+
WARNING: No agents configured. Set manager.agents to connect to USB/IP agents.
13+
{{- end }}
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 "dra-usbip-driver.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 "dra-usbip-driver.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 "dra-usbip-driver.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "dra-usbip-driver.labels" -}}
37+
helm.sh/chart: {{ include "dra-usbip-driver.chart" . }}
38+
{{ include "dra-usbip-driver.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 "dra-usbip-driver.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "dra-usbip-driver.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 "dra-usbip-driver.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "dra-usbip-driver.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "dra-usbip-driver.fullname" . }}-manager
5+
labels:
6+
{{- include "dra-usbip-driver.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: manager
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
{{- include "dra-usbip-driver.selectorLabels" . | nindent 6 }}
13+
app.kubernetes.io/component: manager
14+
template:
15+
metadata:
16+
labels:
17+
{{- include "dra-usbip-driver.labels" . | nindent 8 }}
18+
app.kubernetes.io/component: manager
19+
spec:
20+
{{- with .Values.imagePullSecrets }}
21+
imagePullSecrets:
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
serviceAccountName: {{ include "dra-usbip-driver.serviceAccountName" . }}-manager
25+
containers:
26+
- name: manager
27+
image: "{{ .Values.manager.image.repository }}:{{ .Values.manager.image.tag | default .Chart.AppVersion }}"
28+
imagePullPolicy: {{ .Values.manager.image.pullPolicy }}
29+
command: ["/manager"]
30+
args:
31+
{{- range .Values.manager.agents }}
32+
- --agent={{ . }}
33+
{{- end }}
34+
{{- with .Values.manager.resources }}
35+
resources:
36+
{{- toYaml . | nindent 12 }}
37+
{{- end }}
38+
{{- with .Values.manager.nodeSelector }}
39+
nodeSelector:
40+
{{- toYaml . | nindent 8 }}
41+
{{- end }}
42+
{{- with .Values.manager.affinity }}
43+
affinity:
44+
{{- toYaml . | nindent 8 }}
45+
{{- end }}
46+
{{- with .Values.manager.tolerations }}
47+
tolerations:
48+
{{- toYaml . | nindent 8 }}
49+
{{- end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: {{ include "dra-usbip-driver.fullname" . }}-manager
5+
labels:
6+
{{- include "dra-usbip-driver.labels" . | nindent 4 }}
7+
rules:
8+
- apiGroups:
9+
- resource.k8s.io
10+
resources:
11+
- resourceslices
12+
verbs: ["*"]

0 commit comments

Comments
 (0)