Skip to content

Commit a32dfa4

Browse files
authored
Merge pull request #219 from Madhu-1/csi-driver-helm-charts
chart: Add helm charts for ceph-csi drivers
2 parents 54985e5 + 85b1294 commit a32dfa4

28 files changed

+1876
-9
lines changed

.github/workflows/test-chart.yml

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ permissions:
77
contents: read
88

99
jobs:
10-
test-operator:
11-
name: operator chart
10+
test-helm:
11+
name: helm charts
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Clone the code
@@ -35,25 +35,55 @@ jobs:
3535
run: |
3636
make docker-build
3737
38-
- name: Install Helm
38+
- name: Install helm
3939
run: |
4040
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
4141
42-
- name: Verify Helm installation
42+
- name: Verify helm installation
4343
run: helm version
4444

45-
- name: Lint Helm Chart
45+
- name: Lint operator helm chart
4646
run: |
4747
helm lint ./deploy/charts/ceph-csi-operator
4848
49-
- name: Install Helm chart for project
49+
- name: Install operator helm chart
5050
run: |
51-
helm install my-release ./deploy/charts/ceph-csi-operator --create-namespace --namespace ceph-csi-operator-system
51+
helm install csi-operator ./deploy/charts/ceph-csi-operator --create-namespace --namespace ceph-csi-operator-system
5252
53-
- name: Check Helm release status
53+
- name: Check operator helm release status
5454
run: |
55-
helm status my-release --namespace ceph-csi-operator-system
55+
helm status csi-operator --namespace ceph-csi-operator-system
5656
5757
- name: Check operator is running
5858
run: |
5959
for i in {1..180}; do kubectl get pods -l app.kubernetes.io/name=ceph-csi-operator -n ceph-csi-operator-system -o jsonpath='{.items[0].status.phase}' | grep -q "Running" && exit 0 || sleep 1; done; echo "Pod not running after 3 minutes"; exit 1
60+
61+
- name: Patch operator to watch csi driver namespace
62+
run: |
63+
kubectl patch deployment csi-operator-ceph-csi-operator-controller-manager -nceph-csi-operator-system --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/env/2/value", "value": "csi-driver"}]'
64+
65+
- name: Lint csi driver helm chart
66+
run: |
67+
helm lint ./deploy/charts/ceph-csi-drivers
68+
69+
- name: Install csi driver helm chart
70+
run: |
71+
helm install csi-driver ./deploy/charts/ceph-csi-drivers --create-namespace --namespace csi-driver
72+
73+
- name: Check csi driver helm release status
74+
run: |
75+
helm status csi-driver --namespace csi-driver
76+
77+
- name: Check csi pods are running
78+
run: |
79+
for i in {1..180}; do
80+
if [ $(kubectl get pods -n csi-driver --field-selector=status.phase=Running --no-headers | wc -l) -eq 6 ]; then
81+
exit 0;
82+
fi
83+
sleep 1;
84+
done;
85+
kubectl get pods,deployment,daemonset,replicaset -oyaml -n csi-driver
86+
kubectl get pods,deployment,daemonset,replicaset -n csi-driver
87+
kubectl logs -l app.kubernetes.io/instance=ceph-csi-operator -nceph-csi-operator-system
88+
echo "Pod(s) not running after 3 minutes";
89+
exit 1;
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v2
2+
name: ceph-csi-drivers
3+
description: A Helm chart for Ceph CSI drivers
4+
# A chart can be either an 'application' or a 'library' chart.
5+
#
6+
# Application charts are a collection of templates that can be packaged into versioned archives
7+
# to be deployed.
8+
#
9+
# Library charts provide useful utilities or functions for the chart developer. They're included as
10+
# a dependency of application charts to inject those utilities and functions into the rendering
11+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
12+
type: application
13+
# This is the chart version. This version number should be incremented each time you make changes
14+
# to the chart and its templates, including the app version.
15+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
16+
version: 0.2.0
17+
# This is the version number of the application being deployed. This version number should be
18+
# incremented each time you make changes to the application. Versions are not expected to
19+
# follow Semantic Versioning. They should reflect the version the application is using.
20+
# It is recommended to use it with quotes.
21+
appVersion: "0.2.0"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "ceph-csi-drivers.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 "ceph-csi-drivers.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 "ceph-csi-drivers.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "ceph-csi-drivers.labels" -}}
37+
helm.sh/chart: {{ include "ceph-csi-drivers.chart" . }}
38+
{{ include "ceph-csi-drivers.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 "ceph-csi-drivers.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "ceph-csi-drivers.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 "ceph-csi-drivers.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "ceph-csi-drivers.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{/* Helper function to normalize the driver name */}}
65+
{{- define "normalizeDriverName" -}}
66+
{{- . | lower | replace "." "-" -}}
67+
{{- end -}}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{- $root := . -}}
2+
{{- range $cephConnection := .Values.cephConnections -}}
3+
{{- if $cephConnection.name -}}
4+
apiVersion: csi.ceph.io/v1alpha1
5+
kind: CephConnection
6+
metadata:
7+
name: {{ $cephConnection.name }}
8+
namespace: {{ $root.Release.Namespace }}
9+
spec:
10+
monitors:
11+
{{- range $cephConnection.monitors }}
12+
- {{ . }}
13+
{{- end }}
14+
rbdMirrorDaemonCount: {{ $cephConnection.rbdMirrorDaemonCount }}
15+
readAffinity:
16+
crushLocationLabels:
17+
{{- range $cephConnection.crushLocationLabels }}
18+
- {{ . }}
19+
{{- end }}
20+
{{- end }}
21+
{{- end }}
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
{{- $root := . -}}
2+
{{- range $driver := .Values.drivers -}}
3+
{{- if hasSuffix "cephfs.csi.ceph.com" $driver.name }}
4+
{{- $normalizedDriverName := include "normalizeDriverName" $driver.name }}
5+
apiVersion: rbac.authorization.k8s.io/v1
6+
kind: ClusterRole
7+
metadata:
8+
name: {{ $normalizedDriverName }}-ctrlplugin-cr
9+
rules:
10+
- apiGroups:
11+
- ""
12+
resources:
13+
- secrets
14+
verbs:
15+
- get
16+
- list
17+
- apiGroups:
18+
- ""
19+
resources:
20+
- configmaps
21+
verbs:
22+
- get
23+
- apiGroups:
24+
- ""
25+
resources:
26+
- nodes
27+
verbs:
28+
- get
29+
- list
30+
- watch
31+
- apiGroups:
32+
- storage.k8s.io
33+
resources:
34+
- csinodes
35+
verbs:
36+
- get
37+
- list
38+
- watch
39+
- apiGroups:
40+
- ""
41+
resources:
42+
- persistentvolumes
43+
verbs:
44+
- get
45+
- list
46+
- watch
47+
- create
48+
- delete
49+
- patch
50+
- update
51+
- apiGroups:
52+
- ""
53+
resources:
54+
- persistentvolumeclaims
55+
verbs:
56+
- get
57+
- list
58+
- watch
59+
- patch
60+
- update
61+
- apiGroups:
62+
- storage.k8s.io
63+
resources:
64+
- storageclasses
65+
verbs:
66+
- get
67+
- list
68+
- watch
69+
- apiGroups:
70+
- ""
71+
resources:
72+
- events
73+
verbs:
74+
- list
75+
- watch
76+
- create
77+
- update
78+
- patch
79+
- apiGroups:
80+
- storage.k8s.io
81+
resources:
82+
- volumeattachments
83+
verbs:
84+
- get
85+
- list
86+
- watch
87+
- patch
88+
- apiGroups:
89+
- storage.k8s.io
90+
resources:
91+
- volumeattachments/status
92+
verbs:
93+
- patch
94+
- apiGroups:
95+
- ""
96+
resources:
97+
- persistentvolumeclaims/status
98+
verbs:
99+
- patch
100+
- apiGroups:
101+
- snapshot.storage.k8s.io
102+
resources:
103+
- volumesnapshots
104+
verbs:
105+
- get
106+
- list
107+
- apiGroups:
108+
- snapshot.storage.k8s.io
109+
resources:
110+
- volumesnapshotclasses
111+
verbs:
112+
- get
113+
- list
114+
- watch
115+
- apiGroups:
116+
- snapshot.storage.k8s.io
117+
resources:
118+
- volumesnapshotcontents
119+
verbs:
120+
- get
121+
- list
122+
- watch
123+
- patch
124+
- update
125+
- apiGroups:
126+
- snapshot.storage.k8s.io
127+
resources:
128+
- volumesnapshotcontents/status
129+
verbs:
130+
- update
131+
- patch
132+
- apiGroups:
133+
- groupsnapshot.storage.k8s.io
134+
resources:
135+
- volumegroupsnapshotclasses
136+
verbs:
137+
- get
138+
- list
139+
- watch
140+
- apiGroups:
141+
- groupsnapshot.storage.k8s.io
142+
resources:
143+
- volumegroupsnapshotcontents
144+
verbs:
145+
- get
146+
- list
147+
- watch
148+
- update
149+
- patch
150+
- apiGroups:
151+
- groupsnapshot.storage.k8s.io
152+
resources:
153+
- volumegroupsnapshotcontents/status
154+
verbs:
155+
- update
156+
- patch
157+
- apiGroups:
158+
- ""
159+
resources:
160+
- serviceaccounts
161+
verbs:
162+
- get
163+
- apiGroups:
164+
- ""
165+
resources:
166+
- serviceaccounts/token
167+
verbs:
168+
- create
169+
{{- end }}
170+
{{- end }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- $root := . -}}
2+
{{- range $driver := .Values.drivers -}}
3+
{{- if hasSuffix "cephfs.csi.ceph.com" $driver.name }}
4+
{{- $normalizedDriverName := include "normalizeDriverName" $driver.name }}
5+
apiVersion: rbac.authorization.k8s.io/v1
6+
kind: ClusterRoleBinding
7+
metadata:
8+
name: {{ $normalizedDriverName }}-ctrlplugin-crb
9+
roleRef:
10+
apiGroup: rbac.authorization.k8s.io
11+
kind: ClusterRole
12+
name: {{ $normalizedDriverName }}-ctrlplugin-cr
13+
subjects:
14+
- kind: ServiceAccount
15+
name: {{ $normalizedDriverName }}-ctrlplugin-sa
16+
namespace: {{ $root.Release.Namespace }}
17+
{{- end }}
18+
{{- end }}

0 commit comments

Comments
 (0)