Skip to content
Merged
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
48 changes: 39 additions & 9 deletions .github/workflows/test-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ permissions:
contents: read

jobs:
test-operator:
name: operator chart
test-helm:
name: helm charts
runs-on: ubuntu-latest
steps:
- name: Clone the code
Expand All @@ -35,25 +35,55 @@ jobs:
run: |
make docker-build

- name: Install Helm
- name: Install helm
run: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

- name: Verify Helm installation
- name: Verify helm installation
run: helm version

- name: Lint Helm Chart
- name: Lint operator helm chart
run: |
helm lint ./deploy/charts/ceph-csi-operator

- name: Install Helm chart for project
- name: Install operator helm chart
run: |
helm install my-release ./deploy/charts/ceph-csi-operator --create-namespace --namespace ceph-csi-operator-system
helm install csi-operator ./deploy/charts/ceph-csi-operator --create-namespace --namespace ceph-csi-operator-system

- name: Check Helm release status
- name: Check operator helm release status
run: |
helm status my-release --namespace ceph-csi-operator-system
helm status csi-operator --namespace ceph-csi-operator-system

- name: Check operator is running
run: |
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

- name: Patch operator to watch csi driver namespace
run: |
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"}]'

- name: Lint csi driver helm chart
run: |
helm lint ./deploy/charts/ceph-csi-drivers

- name: Install csi driver helm chart
run: |
helm install csi-driver ./deploy/charts/ceph-csi-drivers --create-namespace --namespace csi-driver

- name: Check csi driver helm release status
run: |
helm status csi-driver --namespace csi-driver

- name: Check csi pods are running
run: |
for i in {1..180}; do
if [ $(kubectl get pods -n csi-driver --field-selector=status.phase=Running --no-headers | wc -l) -eq 6 ]; then
exit 0;
fi
sleep 1;
done;
kubectl get pods,deployment,daemonset,replicaset -oyaml -n csi-driver
kubectl get pods,deployment,daemonset,replicaset -n csi-driver
kubectl logs -l app.kubernetes.io/instance=ceph-csi-operator -nceph-csi-operator-system
echo "Pod(s) not running after 3 minutes";
exit 1;
23 changes: 23 additions & 0 deletions deploy/charts/ceph-csi-drivers/.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/
21 changes: 21 additions & 0 deletions deploy/charts/ceph-csi-drivers/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: ceph-csi-drivers
description: A Helm chart for Ceph CSI drivers
# 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.2.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.2.0"
67 changes: 67 additions & 0 deletions deploy/charts/ceph-csi-drivers/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "ceph-csi-drivers.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 "ceph-csi-drivers.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 "ceph-csi-drivers.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "ceph-csi-drivers.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ceph-csi-drivers.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "ceph-csi-drivers.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ceph-csi-drivers.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/* Helper function to normalize the driver name */}}
{{- define "normalizeDriverName" -}}
{{- . | lower | replace "." "-" -}}
{{- end -}}
21 changes: 21 additions & 0 deletions deploy/charts/ceph-csi-drivers/templates/cephConnection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- $root := . -}}
{{- range $cephConnection := .Values.cephConnections -}}
{{- if $cephConnection.name -}}
apiVersion: csi.ceph.io/v1alpha1
kind: CephConnection
metadata:
name: {{ $cephConnection.name }}
namespace: {{ $root.Release.Namespace }}
spec:
monitors:
{{- range $cephConnection.monitors }}
- {{ . }}
{{- end }}
rbdMirrorDaemonCount: {{ $cephConnection.rbdMirrorDaemonCount }}
readAffinity:
crushLocationLabels:
{{- range $cephConnection.crushLocationLabels }}
- {{ . }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{{- $root := . -}}
{{- range $driver := .Values.drivers -}}
{{- if hasSuffix "cephfs.csi.ceph.com" $driver.name }}
{{- $normalizedDriverName := include "normalizeDriverName" $driver.name }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ $normalizedDriverName }}-ctrlplugin-cr
rules:
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- storage.k8s.io
resources:
- csinodes
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- persistentvolumes
verbs:
- get
- list
- watch
- create
- delete
- patch
- update
- apiGroups:
- ""
resources:
- persistentvolumeclaims
verbs:
- get
- list
- watch
- patch
- update
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- list
- watch
- create
- update
- patch
- apiGroups:
- storage.k8s.io
resources:
- volumeattachments
verbs:
- get
- list
- watch
- patch
- apiGroups:
- storage.k8s.io
resources:
- volumeattachments/status
verbs:
- patch
- apiGroups:
- ""
resources:
- persistentvolumeclaims/status
verbs:
- patch
- apiGroups:
- snapshot.storage.k8s.io
resources:
- volumesnapshots
verbs:
- get
- list
- apiGroups:
- snapshot.storage.k8s.io
resources:
- volumesnapshotclasses
verbs:
- get
- list
- watch
- apiGroups:
- snapshot.storage.k8s.io
resources:
- volumesnapshotcontents
verbs:
- get
- list
- watch
- patch
- update
- apiGroups:
- snapshot.storage.k8s.io
resources:
- volumesnapshotcontents/status
verbs:
- update
- patch
- apiGroups:
- groupsnapshot.storage.k8s.io
resources:
- volumegroupsnapshotclasses
verbs:
- get
- list
- watch
- apiGroups:
- groupsnapshot.storage.k8s.io
resources:
- volumegroupsnapshotcontents
verbs:
- get
- list
- watch
- update
- patch
- apiGroups:
- groupsnapshot.storage.k8s.io
resources:
- volumegroupsnapshotcontents/status
verbs:
- update
- patch
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- get
- apiGroups:
- ""
resources:
- serviceaccounts/token
verbs:
- create
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- $root := . -}}
{{- range $driver := .Values.drivers -}}
{{- if hasSuffix "cephfs.csi.ceph.com" $driver.name }}
{{- $normalizedDriverName := include "normalizeDriverName" $driver.name }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ $normalizedDriverName }}-ctrlplugin-crb
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ $normalizedDriverName }}-ctrlplugin-cr
subjects:
- kind: ServiceAccount
name: {{ $normalizedDriverName }}-ctrlplugin-sa
namespace: {{ $root.Release.Namespace }}
{{- end }}
{{- end }}
Loading
Loading