Skip to content

Commit afda7e0

Browse files
committed
ci: prepare for e2e test
1. prepare model-csi-driver helm chart 2. install kind cluster and helm 3. install model-csi-driver helm to cluster Signed-off-by: imeoer <[email protected]>
1 parent 18269c6 commit afda7e0

File tree

8 files changed

+372
-0
lines changed

8 files changed

+372
-0
lines changed

.github/workflows/e2e.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Run E2E Test
2+
3+
on:
4+
push:
5+
branches: [main, release-*]
6+
pull_request:
7+
branches: [main, release-*]
8+
9+
jobs:
10+
run-e2e-test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Cache Go modules
18+
uses: actions/cache@v4
19+
with:
20+
path: |
21+
~/.cache/go-build
22+
~/go/pkg/mod
23+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
24+
restore-keys: |
25+
${{ runner.os }}-go-
26+
27+
- name: Build binaries
28+
run: |
29+
make release
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Build Docker Image
35+
run: |
36+
docker build -t model-csi-driver:latest -f misc/Dockerfile .
37+
38+
- name: Install Kind
39+
run: |
40+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.30.0/kind-linux-amd64
41+
chmod +x ./kind
42+
sudo mv ./kind /usr/local/bin/kind
43+
44+
- name: Create Kind Cluster
45+
run: |
46+
kind create cluster --wait 120s
47+
48+
- name: Load docker image into kind
49+
run: |
50+
kind load docker-image model-csi-driver:latest
51+
52+
- name: Install Helm
53+
run: |
54+
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
55+
56+
- name: Check cluster and helm
57+
run: |
58+
kubectl get nodes
59+
kubectl cluster-info
60+
helm version
61+
62+
- name: Deploy model-csi-driver chart
63+
run: |
64+
helm upgrade --install model-csi-driver ./charts/model-csi-driver --namespace model-csi --create-namespace
65+
66+
# - name: Wait for model-csi-driver pods to be ready
67+
# run: |
68+
# kubectl wait --for=condition=Ready pods --all --namespace model-csi --timeout=60s
69+
70+
- name: Start tmate session
71+
uses: mxschmitt/action-tmate@v3
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/model-csi-driver/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: model-csi-driver
3+
description: Kubernetes CSI Driver for serving OCI model artifacts
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: "1.16.0"
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 "model-csi-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 "model-csi-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 "model-csi-driver.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "model-csi-driver.labels" -}}
37+
helm.sh/chart: {{ include "model-csi-driver.chart" . }}
38+
{{ include "model-csi-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 "model-csi-driver.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "model-csi-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 "model-csi-driver.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "model-csi-driver.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: config
5+
namespace: model-csi
6+
data:
7+
config.yaml: |-
8+
service_name: {{ .Values.config.serviceName }}
9+
root_dir: {{ .Values.config.rootDir }}
10+
csi_endpoint: unix:///csi/csi.sock
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
namespace: {{ .Values.namespace }}
5+
name: {{ include "model-csi-driver.fullname" . }}
6+
labels:
7+
{{- include "model-csi-driver.labels" . | nindent 4 }}
8+
spec:
9+
selector:
10+
matchLabels:
11+
{{- include "model-csi-driver.selectorLabels" . | nindent 6 }}
12+
{{- with .Values.updateStrategy }}
13+
updateStrategy:
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
template:
17+
metadata:
18+
{{- with .Values.podAnnotations }}
19+
annotations:
20+
{{- toYaml . | nindent 8 }}
21+
{{- end }}
22+
labels:
23+
{{- include "model-csi-driver.selectorLabels" . | nindent 8 }}
24+
{{- with .Values.podLabels }}
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
spec:
28+
{{- with .Values.imagePullSecrets }}
29+
imagePullSecrets:
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
{{- if .Values.hostNetwork }}
33+
hostNetwork: {{ .Values.hostNetwork }}
34+
{{- end }}
35+
containers:
36+
- name: csi-driver-registrar
37+
image: "{{ .Values.registrar.image.repository }}:{{ .Values.registrar.image.tag }}"
38+
imagePullPolicy: {{ .Values.registrar.image.pullPolicy | default "IfNotPresent" }}
39+
args:
40+
- "--v=5"
41+
- "--csi-address=/csi/csi.sock"
42+
- "--kubelet-registration-path=/var/lib/kubelet/plugins/{{ .Values.config.serviceName }}/csi.sock"
43+
resources:
44+
limits:
45+
cpu: "0.5"
46+
memory: 256Mi
47+
ephemeral-storage: 1Gi
48+
requests:
49+
cpu: 0
50+
memory: 0
51+
ephemeral-storage: 0
52+
initialDelaySeconds: 30
53+
timeoutSeconds: 15
54+
volumeMounts:
55+
- name: plugin-dir
56+
mountPath: /csi
57+
- name: {{ .Chart.Name }}
58+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
59+
imagePullPolicy: {{ .Values.image.pullPolicy | default "IfNotPresent" }}
60+
command:
61+
- /usr/bin/model-csi-driver
62+
- --config
63+
- /etc/model-csi-driver/config.yaml
64+
livenessProbe:
65+
exec:
66+
command:
67+
- /bin/sh
68+
- -c
69+
- |
70+
stat /csi/csi.sock
71+
failureThreshold: 2
72+
initialDelaySeconds: 5
73+
periodSeconds: 10
74+
{{- with .Values.args }}
75+
args:
76+
{{- toYaml . | nindent 12 }}
77+
{{- end }}
78+
env:
79+
- name: POD_IP
80+
valueFrom:
81+
fieldRef:
82+
apiVersion: v1
83+
fieldPath: status.podIP
84+
- name: X_CSI_MODE
85+
value: node
86+
- name: CSI_NODE_ID
87+
valueFrom:
88+
fieldRef:
89+
fieldPath: spec.nodeName
90+
{{- with .Values.env }}
91+
{{- toYaml . | nindent 12 }}
92+
{{- end }}
93+
securityContext:
94+
privileged: true
95+
capabilities:
96+
add: ["SYS_ADMIN"]
97+
allowPrivilegeEscalation: true
98+
resources:
99+
{{- toYaml .Values.resources | nindent 12 }}
100+
volumeMounts:
101+
- name: plugin-dir
102+
mountPath: /csi
103+
- mountPath: /etc/model-csi-driver
104+
name: config-dir
105+
readOnly: true
106+
- mountPath: {{ .Values.config.rootDir }}
107+
name: root-dir
108+
mountPropagation: "Bidirectional"
109+
{{- with .Values.volumeMounts }}
110+
{{- toYaml . | nindent 12 }}
111+
{{- end }}
112+
{{- with .Values.livenessProbe }}
113+
livenessProbe:
114+
{{- toYaml . | nindent 12 }}
115+
{{- end }}
116+
{{- with .Values.readinessProbe }}
117+
readinessProbe:
118+
{{- toYaml . | nindent 12 }}
119+
{{- end }}
120+
volumes:
121+
- name: plugin-dir
122+
hostPath:
123+
path: /var/lib/kubelet/plugins/{{ .Values.config.serviceName }}
124+
type: DirectoryOrCreate
125+
- name: root-dir
126+
hostPath:
127+
path: {{ .Values.config.rootDir }}
128+
type: DirectoryOrCreate
129+
- name: config-dir
130+
configMap:
131+
defaultMode: 420
132+
name: config
133+
{{- with .Values.priorityClassName }}
134+
priorityClassName: {{ . }}
135+
{{- end }}
136+
tolerations:
137+
{{- toYaml .Values.tolerations | nindent 8 }}
138+
nodeSelector:
139+
{{- toYaml .Values.nodeSelector | nindent 8 }}
140+
affinity:
141+
{{- toYaml .Values.affinity | nindent 8 }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Default values for model-csi-driver.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
namespace: model-csi
6+
7+
image:
8+
repository: model-csi-driver
9+
pullPolicy: IfNotPresent
10+
tag: latest
11+
12+
registrar:
13+
image:
14+
repository: k8s.gcr.io/sig-storage/csi-node-driver-registrar
15+
pullPolicy: IfNotPresent
16+
tag: v2.5.0
17+
18+
resources:
19+
limits:
20+
cpu: 1
21+
memory: 1Gi
22+
ephemeral-storage: 1Gi
23+
requests:
24+
cpu: 0
25+
memory: 0
26+
ephemeral-storage: 0
27+
28+
config:
29+
serviceName: model.csi.modelpack.org
30+
rootDir: /var/lib/model-csi
31+
32+
imagePullSecrets: []
33+
nameOverride: ""
34+
fullnameOverride: ""
35+
podAnnotations: {}
36+
nodeSelector: {}
37+
tolerations: []
38+
affinity: {}

misc/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM gcr.io/distroless/static
2+
COPY ./model-csi-driver /usr/bin/model-csi-driver
3+
ENTRYPOINT ["/usr/bin/model-csi-driver"]

0 commit comments

Comments
 (0)