Skip to content

Commit 4fbdcb2

Browse files
authored
Merge pull request #91 from Leaseweb/add-csi-charts
Adding CloudStack CSI Charts
2 parents bc56b17 + 9c5f447 commit 4fbdcb2

18 files changed

+1151
-1
lines changed

.github/workflows/chart-lints.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Lint Charts
2+
on:
3+
pull_request:
4+
paths:
5+
- 'charts/**'
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Set up Helm
16+
uses: azure/[email protected]
17+
with:
18+
version: v3.14.1
19+
20+
- uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.10'
23+
check-latest: true
24+
25+
# see example https://github.com/helm/chart-testing-action
26+
- name: Set up chart-testing
27+
uses: helm/[email protected]
28+
29+
- name: Run chart-testing (list-changed)
30+
id: list-changed
31+
run: |
32+
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
33+
if [[ -n "$changed" ]]; then
34+
echo "changed=true" >> "$GITHUB_OUTPUT"
35+
fi
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release Charts
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'charts/**'
9+
10+
jobs:
11+
release:
12+
permissions:
13+
contents: write
14+
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Configure Git
23+
run: |
24+
git config user.name "$GITHUB_ACTOR"
25+
git config user.email "[email protected]"
26+
27+
- name: Run chart-releaser
28+
uses: helm/[email protected]
29+
with:
30+
version: v1.6.0
31+
charts_dir: charts
32+
env:
33+
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
CR_GENERATE_RELEASE_NOTES: true

.github/workflows/pr-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: golangci-lint
1313
uses: golangci/golangci-lint-action@v3
1414
with:
15-
version: v1.53.2
15+
version: v1.56.2
1616
args: --timeout=5m
1717

1818
build:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/test/e2e/e2e.test
33
/test/e2e/ginkgo
44
cloud-config
5+
/vendor
6+

.helmignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
.vscode/

charts/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: cloudstack-csi
3+
description: A Helm chart for Kubernetes
4+
type: application
5+
version: 1.0.0
6+
appVersion: 0.3.0
7+
sources:
8+
- https://github.com/Leaseweb/cloudstack-csi-driver
9+
keywords:
10+
- csi
11+
- cloudStack

charts/templates/_helpers.tpl

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "csi.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "csi.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "csi.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "csi.labels" -}}
38+
app.kubernetes.io/name: {{ include "csi.name" . }}
39+
helm.sh/chart: {{ include "csi.chart" . }}
40+
app.kubernetes.io/instance: {{ .Release.Name }}
41+
{{- if .Chart.AppVersion }}
42+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
43+
{{- end }}
44+
app.kubernetes.io/managed-by: {{ .Release.Service }}
45+
{{- end -}}
46+
47+
48+
{{/*
49+
Create the name of the service account to use
50+
*/}}
51+
{{- define "csi.serviceAccountName" -}}
52+
{{- if .Values.serviceAccount.create -}}
53+
{{ default (include "csi.fullname" .) .Values.serviceAccount.name }}
54+
{{- else -}}
55+
{{ default "default" .Values.serviceAccount.name }}
56+
{{- end -}}
57+
{{- end -}}
58+
59+
{{/*
60+
Create unified labels for csi components
61+
*/}}
62+
{{- define "csi.common.matchLabels" -}}
63+
app: {{ template "csi.name" . }}
64+
release: {{ .Release.Name }}
65+
{{- end -}}
66+
67+
{{- define "csi.common.metaLabels" -}}
68+
chart: {{ template "csi.chart" . }}
69+
heritage: {{ .Release.Service }}
70+
{{- if .Values.extraLabels }}
71+
{{ toYaml .Values.extraLabels -}}
72+
{{- end }}
73+
{{- end -}}
74+
75+
{{- define "csi.controller.matchLabels" -}}
76+
component: controller
77+
{{ include "csi.common.matchLabels" . }}
78+
{{- end -}}
79+
80+
{{- define "csi.controller.labels" -}}
81+
{{ include "csi.controller.matchLabels" . }}
82+
{{ include "csi.common.metaLabels" . }}
83+
{{- end -}}
84+
85+
{{- define "csi.node.matchLabels" -}}
86+
component: node
87+
{{ include "csi.common.matchLabels" . }}
88+
{{- end -}}
89+
90+
{{- define "csi.node.labels" -}}
91+
{{ include "csi.node.matchLabels" . }}
92+
{{ include "csi.common.metaLabels" . }}
93+
{{- end -}}
94+
95+
{{/*
96+
Create cloud-config makro.
97+
*/}}
98+
{{- define "cloudConfig" -}}
99+
[Global]
100+
{{- range $key, $value := .Values.cloudConfigData.global }}
101+
{{ $key }} = {{ $value | quote }}
102+
{{- end }}
103+
{{- end -}}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{{ if .Values.rbac.create }}
2+
# This YAML file contains Cluster Role objects,
3+
# which are necessary to run cloudstack-csi-controller
4+
{{ $enableLeaderElection := gt (int .Values.controller.replicaCount) 1 }}
5+
---
6+
# external Attacher
7+
kind: ClusterRole
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
metadata:
10+
name: csi-attacher-role
11+
annotations:
12+
{{- with .Values.commonAnnotations }}
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
rules:
16+
- apiGroups: [""]
17+
resources: ["persistentvolumes"]
18+
verbs: ["get", "list", "watch", "patch"]
19+
- apiGroups: ["storage.k8s.io"]
20+
resources: ["csinodes"]
21+
verbs: ["get", "list", "watch"]
22+
- apiGroups: ["storage.k8s.io"]
23+
resources: ["volumeattachments"]
24+
verbs: ["get", "list", "watch", "patch"]
25+
- apiGroups: ["storage.k8s.io"]
26+
resources: ["volumeattachments/status"]
27+
verbs: ["patch"]
28+
{{- if $enableLeaderElection}}
29+
# leader election
30+
- apiGroups: [coordination.k8s.io]
31+
resources: [leases]
32+
verbs: ["get", "watch", "list", "delete", "update", "create"]
33+
{{- end}}
34+
---
35+
# external Provisioner
36+
kind: ClusterRole
37+
apiVersion: rbac.authorization.k8s.io/v1
38+
metadata:
39+
name: csi-provisioner-role
40+
annotations:
41+
{{- with .Values.commonAnnotations }}
42+
{{- toYaml . | nindent 4 }}
43+
{{- end }}
44+
rules:
45+
- apiGroups: [""]
46+
resources: ["persistentvolumes"]
47+
verbs: ["get", "list", "watch", "create", "delete"]
48+
- apiGroups: [""]
49+
resources: ["persistentvolumeclaims"]
50+
verbs: ["get", "list", "watch", "update"]
51+
- apiGroups: ["storage.k8s.io"]
52+
resources: ["storageclasses"]
53+
verbs: ["get", "list", "watch"]
54+
- apiGroups: [""]
55+
resources: ["nodes"]
56+
verbs: ["get", "list", "watch"]
57+
- apiGroups: ["storage.k8s.io"]
58+
resources: ["csinodes"]
59+
verbs: ["get", "list", "watch"]
60+
- apiGroups: [""]
61+
resources: ["events"]
62+
verbs: ["list", "watch", "create", "update", "patch"]
63+
- apiGroups: ["snapshot.storage.k8s.io"]
64+
resources: ["volumesnapshots"]
65+
verbs: ["get", "list"]
66+
- apiGroups: ["snapshot.storage.k8s.io"]
67+
resources: ["volumesnapshotcontents"]
68+
verbs: ["get", "list"]
69+
{{- if $enableLeaderElection}}
70+
# leader election
71+
- apiGroups: [coordination.k8s.io]
72+
resources: [leases]
73+
verbs: ["get", "watch", "list", "delete", "update", "create"]
74+
{{- end}}
75+
---
76+
# external Resizer
77+
kind: ClusterRole
78+
apiVersion: rbac.authorization.k8s.io/v1
79+
metadata:
80+
name: csi-resizer-role
81+
rules:
82+
# The following rule should be uncommented for plugins that require secrets
83+
# for provisioning.
84+
# - apiGroups: [""]
85+
# resources: ["secrets"]
86+
# verbs: ["get", "list", "watch"]
87+
- apiGroups: [""]
88+
resources: ["persistentvolumes"]
89+
verbs: ["get", "list", "watch", "patch"]
90+
- apiGroups: [""]
91+
resources: ["persistentvolumeclaims"]
92+
verbs: ["get", "list", "watch"]
93+
- apiGroups: [""]
94+
resources: ["pods"]
95+
verbs: ["get", "list", "watch"]
96+
- apiGroups: [""]
97+
resources: ["persistentvolumeclaims/status"]
98+
verbs: ["patch"]
99+
- apiGroups: [""]
100+
resources: ["events"]
101+
verbs: ["list", "watch", "create", "update", "patch"]
102+
{{- if $enableLeaderElection}}
103+
# leader election
104+
- apiGroups: [coordination.k8s.io]
105+
resources: [leases]
106+
verbs: ["get", "watch", "list", "delete", "update", "create"]
107+
{{- end}}
108+
{{- end}}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{{ if .Values.rbac.create }}
2+
# This YAML file contains Cluster Role Binding objects,
3+
# which are necessary to run cloudstack-csi-controller
4+
---
5+
kind: ClusterRoleBinding
6+
apiVersion: rbac.authorization.k8s.io/v1
7+
metadata:
8+
name: csi-attacher-binding
9+
annotations:
10+
{{- with .Values.commonAnnotations }}
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
subjects:
14+
- kind: ServiceAccount
15+
name: {{ .Values.serviceAccount.name }}
16+
namespace: {{ .Release.Namespace }}
17+
roleRef:
18+
kind: ClusterRole
19+
name: csi-attacher-role
20+
apiGroup: rbac.authorization.k8s.io
21+
---
22+
kind: ClusterRoleBinding
23+
apiVersion: rbac.authorization.k8s.io/v1
24+
metadata:
25+
name: csi-provisioner-binding
26+
annotations:
27+
{{- with .Values.commonAnnotations }}
28+
{{- toYaml . | nindent 4 }}
29+
{{- end }}
30+
subjects:
31+
- kind: ServiceAccount
32+
name: {{ .Values.serviceAccount.name }}
33+
namespace: {{ .Release.Namespace }}
34+
roleRef:
35+
kind: ClusterRole
36+
name: csi-provisioner-role
37+
apiGroup: rbac.authorization.k8s.io
38+
---
39+
kind: ClusterRoleBinding
40+
apiVersion: rbac.authorization.k8s.io/v1
41+
metadata:
42+
name: csi-resizer-binding
43+
annotations:
44+
{{- with .Values.commonAnnotations }}
45+
{{- toYaml . | nindent 4 }}
46+
{{- end }}
47+
subjects:
48+
- kind: ServiceAccount
49+
name: {{ .Values.serviceAccount.name }}
50+
namespace: {{ .Release.Namespace }}
51+
roleRef:
52+
kind: ClusterRole
53+
name: csi-resizer-role
54+
apiGroup: rbac.authorization.k8s.io
55+
{{- end}}

0 commit comments

Comments
 (0)