From dd3139dfb1817770bc190f0e1696c8f991ec64de Mon Sep 17 00:00:00 2001 From: Wong Hoi Sing Edison Date: Thu, 10 Apr 2025 18:19:32 +0800 Subject: [PATCH] helm: Support VolumeSnapshotClass and VolumeGroupSnapshotClass This PR add support for creating VolumeSnapshotClass and VolumeGroupSnapshotClass with helm charts. Both default with `create: false` as StorageClass support. Moreover, it handle the chart release with branch `gh-pages`, by integrate with . The sample helm repo could find from , by: helm repo add ceph-csi https://alvistack.github.io/ceph-ceph-csi helm repo update helm search repo ceph-csi Signed-off-by: Wong Hoi Sing Edison --- PendingReleaseNotes.md | 2 + charts/ceph-csi-cephfs/README.md | 16 +++++ .../templates/groupsnapshotclass.yaml | 30 +++++++++ .../templates/snapshotclass.yaml | 29 ++++++++ charts/ceph-csi-cephfs/values.yaml | 65 ++++++++++++++++++ charts/ceph-csi-rbd/README.md | 16 +++++ .../templates/groupsnapshotclass.yaml | 30 +++++++++ .../ceph-csi-rbd/templates/snapshotclass.yaml | 29 ++++++++ charts/ceph-csi-rbd/values.yaml | 67 +++++++++++++++++++ 9 files changed, 284 insertions(+) create mode 100644 charts/ceph-csi-cephfs/templates/groupsnapshotclass.yaml create mode 100644 charts/ceph-csi-cephfs/templates/snapshotclass.yaml create mode 100644 charts/ceph-csi-rbd/templates/groupsnapshotclass.yaml create mode 100644 charts/ceph-csi-rbd/templates/snapshotclass.yaml diff --git a/PendingReleaseNotes.md b/PendingReleaseNotes.md index b84ea359b..5f09321a8 100644 --- a/PendingReleaseNotes.md +++ b/PendingReleaseNotes.md @@ -4,4 +4,6 @@ ## Features +- helm: Support VolumeSnapshotClass and VolumeGroupSnapshotClass + ## NOTE diff --git a/charts/ceph-csi-cephfs/README.md b/charts/ceph-csi-cephfs/README.md index 7b6edf687..332143532 100644 --- a/charts/ceph-csi-cephfs/README.md +++ b/charts/ceph-csi-cephfs/README.md @@ -214,6 +214,22 @@ charts and their default values. | `storageClass.reclaimPolicy` | Specifies the reclaim policy of the StorageClass | `Delete` | | `storageClass.allowVolumeExpansion` | Specifies whether volume expansion should be allowed | `true` | | `storageClass.mountOptions` | Specifies the mount options | `[]` | +| `volumeSnapshotClass.create` | Specifies whether the VolumeSnapshotClass should be created | `false` | +| `volumeSnapshotClass.name` | Specifies the cephFS VolumeSnapshotClass name | `csi-cephfsplugin-snapclass` | +| `volumeSnapshotClass.annotations` | Specifies the annotations for the cephFS volumeSnapshotClass | `[]` | +| `volumeSnapshotClass.clusterID` | String representing a Ceph cluster to provision storage snapshot from | `` | +| `volumeSnapshotClass.snapshotNamePrefix` | Prefix to use for naming CephFS snapshots | `""` | +| `volumeSnapshotClass.snapshotterSecret` | The secrets have to contain user and/or Ceph admin credentials. | `csi-cephfs-secret` | +| `volumeSnapshotClass.snapshotterSecretNamespace` | Specifies the snapshotter secret namespace | `""` | +| `volumeSnapshotClass.deletionPolicy` | Specifies the deletion policy of the VolumeSnapshotClass | `Delete` | +| `volumeGroupSnapshotClass.name` | Specifies the cephFS VolumeGroupSnapshotClass name | `csi-cephfsplugin-groupsnapclass` | +| `volumeGroupSnapshotClass.annotations` | Specifies the annotations for the cephFS volumeGroupSnapshotClass | `[]` | +| `volumeGroupSnapshotClass.clusterID` | String representing a Ceph cluster to provision storage group snapshot from | `` | +| `volumeGroupSnapshotClass.fsName` | CephFS filesystem name into which the volume shall be created | `myfs` | +| `volumeGroupSnapshotClass.volumeGroupNamePrefix` | Prefix to use for naming CephFS volumeGroups | `""` | +| `volumeGroupSnapshotClass.groupSnapshotterSecret` | The secrets have to contain user and/or Ceph admin credentials. | `csi-cephfs-secret` | +| `volumeGroupSnapshotClass.groupSnapshotterSecretNamespace` | Specifies the groupSnapshotter secret namespace | `""` | +| `volumeGroupSnapshotClass.deletionPolicy` | Specifies the deletion policy of the VolumeGroupSnapshotClass | `Delete` | | `secret.create` | Specifies whether the secret should be created | `false` | | `secret.name` | Specifies the cephFS secret name | `csi-cephfs-secret` | | `secret.userID` | Specifies the user ID of the cephFS secret. | `""` | diff --git a/charts/ceph-csi-cephfs/templates/groupsnapshotclass.yaml b/charts/ceph-csi-cephfs/templates/groupsnapshotclass.yaml new file mode 100644 index 000000000..304f83e37 --- /dev/null +++ b/charts/ceph-csi-cephfs/templates/groupsnapshotclass.yaml @@ -0,0 +1,30 @@ +{{- if .Values.volumeGroupSnapshotClass.create -}} +apiVersion: groupsnapshot.storage.k8s.io/v1beta1 +kind: VolumeGroupSnapshotClass +metadata: + name: {{ .Values.volumeGroupSnapshotClass.name }} +{{- if .Values.volumeGroupSnapshotClass.annotations }} + annotations: +{{ toYaml .Values.volumeGroupSnapshotClass.annotations | indent 4 }} +{{- end }} + labels: + app: {{ include "ceph-csi-cephfs.name" . }} + chart: {{ include "ceph-csi-cephfs.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }} +driver: {{ .Values.driverName }} +parameters: + clusterID: {{ .Values.volumeGroupSnapshotClass.clusterID }} + fsName: {{ .Values.volumeGroupSnapshotClass.fsName }} +{{- if .Values.volumeGroupSnapshotClass.volumeGroupNamePrefix }} + volumeGroupNamePrefix: "{{ .Values.volumeGroupSnapshotClass.volumeGroupNamePrefix }}" +{{- end }} + csi.storage.k8s.io/group-snapshotter-secret-name: {{ .Values.volumeGroupSnapshotClass.groupSnapshotterSecret }} +{{- if .Values.volumeGroupSnapshotClass.groupSnapshotterSecretNamespace }} + csi.storage.k8s.io/group-snapshotter-secret-namespace: {{ .Values.volumeGroupSnapshotClass.groupSnapshotterSecretNamespace }} +{{ else }} + csi.storage.k8s.io/group-snapshotter-secret-namespace: {{ .Release.Namespace }} +{{- end }} +deletionPolicy: {{ .Values.volumeGroupSnapshotClass.deletionPolicy }} +{{- end -}} diff --git a/charts/ceph-csi-cephfs/templates/snapshotclass.yaml b/charts/ceph-csi-cephfs/templates/snapshotclass.yaml new file mode 100644 index 000000000..e603397a9 --- /dev/null +++ b/charts/ceph-csi-cephfs/templates/snapshotclass.yaml @@ -0,0 +1,29 @@ +{{- if .Values.volumeSnapshotClass.create -}} +apiVersion: snapshot.storage.k8s.io/v1 +kind: VolumeSnapshotClass +metadata: + name: {{ .Values.volumeSnapshotClass.name }} +{{- if .Values.volumeSnapshotClass.annotations }} + annotations: +{{ toYaml .Values.volumeSnapshotClass.annotations | indent 4 }} +{{- end }} + labels: + app: {{ include "ceph-csi-cephfs.name" . }} + chart: {{ include "ceph-csi-cephfs.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }} +driver: {{ .Values.driverName }} +parameters: + clusterID: {{ .Values.volumeSnapshotClass.clusterID }} +{{- if .Values.volumeSnapshotClass.snapshotNamePrefix }} + snapshotNamePrefix: "{{ .Values.volumeSnapshotClass.snapshotNamePrefix }}" +{{- end }} + csi.storage.k8s.io/snapshotter-secret-name: {{ .Values.volumeSnapshotClass.snapshotterSecret }} +{{- if .Values.volumeSnapshotClass.snapshotterSecretNamespace }} + csi.storage.k8s.io/snapshotter-secret-namespace: {{ .Values.volumeSnapshotClass.snapshotterSecretNamespace }} +{{ else }} + csi.storage.k8s.io/snapshotter-secret-namespace: {{ .Release.Namespace }} +{{- end }} +deletionPolicy: {{ .Values.volumeSnapshotClass.deletionPolicy }} +{{- end -}} diff --git a/charts/ceph-csi-cephfs/values.yaml b/charts/ceph-csi-cephfs/values.yaml index 586ba92af..c326cb832 100644 --- a/charts/ceph-csi-cephfs/values.yaml +++ b/charts/ceph-csi-cephfs/values.yaml @@ -375,6 +375,71 @@ storageClass: # mountOptions: # - discard +volumeSnapshotClass: + # Specifies whether the VolumeSnapshotClass should be created + create: false + name: csi-cephfsplugin-snapclass + + # Annotations for the VolumeSnapshotClass + # Example: + # annotations: + # storageclass.kubernetes.io/is-default-class: "true" + annotations: {} + + # String representing a Ceph cluster to provision storage snapshot from. + # Should be unique across all Ceph clusters in use for provisioning, + # cannot be greater than 36 bytes in length, and should remain immutable for + # the lifetime of the VolumeSnapshotClass in use. + # Ensure to create an entry in the configmap named ceph-csi-config, based on + # csi-config-map-sample.yaml, to accompany the string chosen to + # represent the Ceph cluster in clusterID below + clusterID: + + # Prefix to use for naming CephFS snapshots. + # If omitted, defaults to "csi-snap-". + # snapshotNamePrefix: "foo-bar-" + snapshotNamePrefix: "" + + # The secrets have to contain user and/or Ceph admin credentials. + snapshotterSecret: csi-cephfs-secret + # If the Namespaces are not specified, the secrets are assumed to + # be in the Release namespace. + snapshotterSecretNamespace: "" + + deletionPolicy: Delete + +volumeGroupSnapshotClass: + # Specifies whether the VolumeGroupSnapshotClass should be created + create: false + name: csi-cephfsplugin-groupsnapclass + + # Annotations for the VolumeGroupSnapshotClass + # Example: + # annotations: + # storageclass.kubernetes.io/is-default-class: "true" + annotations: {} + + # String representing a Ceph cluster to provision storage from. + # Should be unique across all Ceph clusters in use for provisioning, + # cannot be greater than 36 bytes in length, and should remain immutable for + # the lifetime of the VolumeGroupSnapshotClass in use + clusterID: + + # eg: fsName: myfs + fsName: myfs + + # (optional) Prefix to use for naming RBD groups. + # If omitted, defaults to "csi-vol-group-". + volumeGroupNamePrefix: "" + + # The secrets have to contain user and/or Ceph admin credentials. + groupSnapshotterSecret: csi-cephfs-secret + # If the Namespaces are not specified, the secrets are assumed to + # be in the Release namespace. + groupSnapshotterSecretNamespace: "" + + deletionPolicy: Delete + secret: # Specifies whether the secret should be created create: false diff --git a/charts/ceph-csi-rbd/README.md b/charts/ceph-csi-rbd/README.md index 0232b87eb..1a4458b2a 100644 --- a/charts/ceph-csi-rbd/README.md +++ b/charts/ceph-csi-rbd/README.md @@ -212,6 +212,22 @@ charts and their default values. | `storageClass.reclaimPolicy` | Specifies the reclaim policy of the StorageClass | `Delete` | | `storageClass.allowVolumeExpansion` | Specifies whether volume expansion should be allowed | `true` | | `storageClass.mountOptions` | Specifies the mount options for storageClass | `[]` | +| `volumeSnapshotClass.create` | Specifies whether the VolumeSnapshotClass should be created | `false` | +| `volumeSnapshotClass.name` | Specifies the rbd VolumeSnapshotClass name | `csi-rbdplugin-snapclass` | +| `volumeSnapshotClass.annotations` | Specifies the annotations for the rbd volumeSnapshotClass | `[]` | +| `volumeSnapshotClass.clusterID` | String representing a Ceph cluster to provision storage snapshot from | `` | +| `volumeSnapshotClass.snapshotNamePrefix` | Prefix to use for naming RBD snapshots | `""` | +| `volumeSnapshotClass.snapshotterSecret` | The secrets have to contain user and/or Ceph admin credentials. | `csi-rbd-secret` | +| `volumeSnapshotClass.snapshotterSecretNamespace` | Specifies the snapshotter secret namespace | `""` | +| `volumeSnapshotClass.deletionPolicy` | Specifies the deletion policy of the VolumeSnapshotClass | `Delete` | +| `volumeGroupSnapshotClass.name` | Specifies the rbd VolumeGroupSnapshotClass name | `csi-rbdplugin-groupsnapclass` | +| `volumeGroupSnapshotClass.annotations` | Specifies the annotations for the rbd volumeGroupSnapshotClass | `[]` | +| `volumeGroupSnapshotClass.clusterID` | String representing a Ceph cluster to provision storage group snapshot from | `` | +| `volumeGroupSnapshotClass.pool` | Ceph pool into which the RBD group shall be created | `replicapool` | +| `volumeGroupSnapshotClass.volumeGroupNamePrefix` | Prefix to use for naming RBD volumeGroups | `""` | +| `volumeGroupSnapshotClass.groupSnapshotterSecret` | The secrets have to contain user and/or Ceph admin credentials. | `csi-rbd-secret` | +| `volumeGroupSnapshotClass.groupSnapshotterSecretNamespace` | Specifies the groupSnapshotter secret namespace | `""` | +| `volumeGroupSnapshotClass.deletionPolicy` | Specifies the deletion policy of the VolumeGroupSnapshotClass | `Delete` | | `secret.create` | Specifies whether the secret should be created | `false` | | `secret.name` | Specifies the rbd secret name | `csi-rbd-secret` | | `secret.userID` | Specifies the user ID of the rbd secret | `` | diff --git a/charts/ceph-csi-rbd/templates/groupsnapshotclass.yaml b/charts/ceph-csi-rbd/templates/groupsnapshotclass.yaml new file mode 100644 index 000000000..95f269057 --- /dev/null +++ b/charts/ceph-csi-rbd/templates/groupsnapshotclass.yaml @@ -0,0 +1,30 @@ +{{- if .Values.volumeGroupSnapshotClass.create -}} +apiVersion: groupsnapshot.storage.k8s.io/v1beta1 +kind: VolumeGroupSnapshotClass +metadata: + name: {{ .Values.volumeGroupSnapshotClass.name }} +{{- if .Values.volumeGroupSnapshotClass.annotations }} + annotations: +{{ toYaml .Values.volumeGroupSnapshotClass.annotations | indent 4 }} +{{- end }} + labels: + app: {{ include "ceph-csi-rbd.name" . }} + chart: {{ include "ceph-csi-rbd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }} +driver: {{ .Values.driverName }} +parameters: + clusterID: {{ .Values.volumeGroupSnapshotClass.clusterID }} + pool: {{ .Values.volumeGroupSnapshotClass.pool }} +{{- if .Values.volumeGroupSnapshotClass.volumeGroupNamePrefix }} + volumeGroupNamePrefix: "{{ .Values.volumeGroupSnapshotClass.volumeGroupNamePrefix }}" +{{- end }} + csi.storage.k8s.io/group-snapshotter-secret-name: {{ .Values.volumeGroupSnapshotClass.groupSnapshotterSecret }} +{{- if .Values.volumeGroupSnapshotClass.groupSnapshotterSecretNamespace }} + csi.storage.k8s.io/group-snapshotter-secret-namespace: {{ .Values.volumeGroupSnapshotClass.groupSnapshotterSecretNamespace }} +{{ else }} + csi.storage.k8s.io/group-snapshotter-secret-namespace: {{ .Release.Namespace }} +{{- end }} +deletionPolicy: {{ .Values.volumeGroupSnapshotClass.deletionPolicy }} +{{- end -}} diff --git a/charts/ceph-csi-rbd/templates/snapshotclass.yaml b/charts/ceph-csi-rbd/templates/snapshotclass.yaml new file mode 100644 index 000000000..4456b0e20 --- /dev/null +++ b/charts/ceph-csi-rbd/templates/snapshotclass.yaml @@ -0,0 +1,29 @@ +{{- if .Values.volumeSnapshotClass.create -}} +apiVersion: snapshot.storage.k8s.io/v1 +kind: VolumeSnapshotClass +metadata: + name: {{ .Values.volumeSnapshotClass.name }} +{{- if .Values.volumeSnapshotClass.annotations }} + annotations: +{{ toYaml .Values.volumeSnapshotClass.annotations | indent 4 }} +{{- end }} + labels: + app: {{ include "ceph-csi-rbd.name" . }} + chart: {{ include "ceph-csi-rbd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }} +driver: {{ .Values.driverName }} +parameters: + clusterID: {{ .Values.volumeSnapshotClass.clusterID }} +{{- if .Values.volumeSnapshotClass.snapshotNamePrefix }} + snapshotNamePrefix: "{{ .Values.volumeSnapshotClass.snapshotNamePrefix }}" +{{- end }} + csi.storage.k8s.io/snapshotter-secret-name: {{ .Values.volumeSnapshotClass.snapshotterSecret }} +{{- if .Values.volumeSnapshotClass.snapshotterSecretNamespace }} + csi.storage.k8s.io/snapshotter-secret-namespace: {{ .Values.volumeSnapshotClass.snapshotterSecretNamespace }} +{{ else }} + csi.storage.k8s.io/snapshotter-secret-namespace: {{ .Release.Namespace }} +{{- end }} +deletionPolicy: {{ .Values.volumeSnapshotClass.deletionPolicy }} +{{- end -}} diff --git a/charts/ceph-csi-rbd/values.yaml b/charts/ceph-csi-rbd/values.yaml index 991c269d0..ebc1ace4c 100644 --- a/charts/ceph-csi-rbd/values.yaml +++ b/charts/ceph-csi-rbd/values.yaml @@ -526,6 +526,73 @@ storageClass: # mountOptions: # - discard +volumeSnapshotClass: + # Specifies whether the VolumeSnapshotClass should be created + create: false + name: csi-rbdplugin-snapclass + + # Annotations for the VolumeSnapshotClass + # Example: + # annotations: + # storageclass.kubernetes.io/is-default-class: "true" + annotations: {} + + # String representing a Ceph cluster to provision storage snapshot from. + # Should be unique across all Ceph clusters in use for provisioning, + # cannot be greater than 36 bytes in length, and should remain immutable for + # the lifetime of the VolumeSnapshotClass in use. + # Ensure to create an entry in the configmap named ceph-csi-config, based on + # csi-config-map-sample.yaml, to accompany the string chosen to + # represent the Ceph cluster in clusterID below + clusterID: <cluster-id> + + # Prefix to use for naming CephFS snapshots. + # If omitted, defaults to "csi-snap-". + # snapshotNamePrefix: "foo-bar-" + snapshotNamePrefix: "" + + # The secrets have to contain user and/or Ceph admin credentials. + snapshotterSecret: csi-rbd-secret + # If the Namespaces are not specified, the secrets are assumed to + # be in the Release namespace. + snapshotterSecretNamespace: "" + + deletionPolicy: Delete + +volumeGroupSnapshotClass: + # Specifies whether the VolumeGroupSnapshotClass should be created + create: false + name: csi-rbdplugin-groupsnapclass + + # Annotations for the VolumeGroupSnapshotClass + # Example: + # annotations: + # storageclass.kubernetes.io/is-default-class: "true" + annotations: {} + + # String representing a Ceph cluster to provision storage from. + # Should be unique across all Ceph clusters in use for provisioning, + # cannot be greater than 36 bytes in length, and should remain immutable for + # the lifetime of the VolumeGroupSnapshotClass in use + clusterID: <cluster-id> + + # (required) Ceph pool into which the RBD image shall be created + # (optional) if topologyConstrainedPools is provided + # eg: pool: replicapool + pool: replicapool + + # (optional) Prefix to use for naming RBD groups. + # If omitted, defaults to "csi-vol-group-". + volumeGroupNamePrefix: "" + + # The secrets have to contain user and/or Ceph admin credentials. + groupSnapshotterSecret: csi-rbd-secret + # If the Namespaces are not specified, the secrets are assumed to + # be in the Release namespace. + groupSnapshotterSecretNamespace: "" + + deletionPolicy: Delete + # Mount the host /etc/selinux inside pods to support # selinux-enabled filesystems selinuxMount: true