Skip to content

Commit

Permalink
Merge pull request rook#13832 from Madhu-1/template-change-vgsc-rook
Browse files Browse the repository at this point in the history
csi: support volumegroup snapshot
  • Loading branch information
travisn authored Mar 1, 2024
2 parents 02db25c + b47bd35 commit 7ca738e
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 13 deletions.
1 change: 1 addition & 0 deletions Documentation/Helm-Charts/operator-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ The following table lists the configurable parameters of the rook-operator chart
| `csi.enablePluginSelinuxHostMount` | Enable Host mount for `/etc/selinux` directory for Ceph CSI nodeplugins | `false` |
| `csi.enableRBDSnapshotter` | Enable Snapshotter in RBD provisioner pod | `true` |
| `csi.enableRbdDriver` | Enable Ceph CSI RBD driver | `true` |
| `csi.enableVolumeGroupSnapshot` | Enable volume group snapshot feature. This feature is enabled by default as long as the necessary CRDs are available in the cluster. | `true` |
| `csi.forceCephFSKernelClient` | Enable Ceph Kernel clients on kernel < 4.17. If your kernel does not support quotas for CephFS you may want to disable this setting. However, this will cause an issue during upgrades with the FUSE client. See the [upgrade guide](https://rook.io/docs/rook/v1.2/ceph-upgrade.html) | `true` |
| `csi.grpcTimeoutInSeconds` | Set GRPC timeout for csi containers (in seconds). It should be >= 120. If this value is not set or is invalid, it defaults to 150 | `150` |
| `csi.imagePullPolicy` | Image pull policy | `"IfNotPresent"` |
Expand Down
1 change: 1 addition & 0 deletions PendingReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ read affinity setting in cephCluster CR (CSIDriverOptions section) in [PR](https

- Kubernetes versions **v1.24** through **v1.29** are supported.
- Ceph daemon pods using the `default` service account now use a new `rook-ceph-default` service account.
- The feature support for VolumeSnapshotGroup has been added to the RBD and CephFS CSI driver.
26 changes: 22 additions & 4 deletions deploy/charts/rook-ceph/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -500,16 +500,25 @@ rules:
verbs: ["patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list"]
verbs: ["get", "list", "watch", "update", "patch", "create"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["get", "list", "watch", "patch", "update"]
verbs: ["get", "list", "watch", "patch", "update", "create"]
- 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"]
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -579,16 +588,25 @@ rules:
verbs: ["patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list", "watch"]
verbs: ["get", "list", "watch", "update", "patch", "create"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["get", "list", "watch", "patch", "update"]
verbs: ["get", "list", "watch", "patch", "update", "create"]
- 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: ["configmaps"]
verbs: ["get"]
Expand Down
1 change: 1 addition & 0 deletions deploy/charts/rook-ceph/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ data:
CSI_ENABLE_OMAP_GENERATOR: {{ .Values.csi.enableOMAPGenerator | quote }}
CSI_ENABLE_HOST_NETWORK: {{ .Values.csi.enableCSIHostNetwork | quote }}
CSI_ENABLE_METADATA: {{ .Values.csi.enableMetadata | quote }}
CSI_ENABLE_VOLUME_GROUP_SNAPSHOT: {{ .Values.csi.enableVolumeGroupSnapshot | quote }}
{{- if .Values.csi.csiDriverNamePrefix }}
CSI_DRIVER_NAME_PREFIX: {{ .Values.csi.csiDriverNamePrefix | quote }}
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions deploy/charts/rook-ceph/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ csi:
# -- Enable Ceph CSI PVC encryption support
enableCSIEncryption: false

# -- Enable volume group snapshot feature. This feature is
# enabled by default as long as the necessary CRDs are available in the cluster.
enableVolumeGroupSnapshot: true
# -- PriorityClassName to be set on csi driver plugin pods
pluginPriorityClassName: system-node-critical

Expand Down
26 changes: 22 additions & 4 deletions deploy/examples/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,25 @@ rules:
verbs: ["patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list"]
verbs: ["get", "list", "watch", "update", "patch", "create"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["get", "list", "watch", "patch", "update"]
verbs: ["get", "list", "watch", "patch", "update", "create"]
- 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"]
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -152,16 +161,25 @@ rules:
verbs: ["patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list", "watch"]
verbs: ["get", "list", "watch", "update", "patch", "create"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["get", "list", "watch", "patch", "update"]
verbs: ["get", "list", "watch", "patch", "update", "create"]
- 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: ["configmaps"]
verbs: ["get"]
Expand Down
4 changes: 4 additions & 0 deletions deploy/examples/operator-openshift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,10 @@ data:
# The GCSI RPC timeout value (in seconds). It should be >= 120. If this variable is not set or is an invalid value, it's default to 150.
CSI_GRPC_TIMEOUT_SECONDS: "150"

# set to false to disable volume group snapshot feature. This feature is
# enabled by default as long as the necessary CRDs are available in the cluster.
CSI_ENABLE_VOLUME_GROUP_SNAPSHOT: "true"

# Enable topology based provisioning.
CSI_ENABLE_TOPOLOGY: "false"
# Domain labels define which node labels to use as domains
Expand Down
3 changes: 3 additions & 0 deletions deploy/examples/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ data:
# set to false to disable deployment of snapshotter container in RBD provisioner pod.
CSI_ENABLE_RBD_SNAPSHOTTER: "true"

# set to false to disable volume group snapshot feature. This feature is
# enabled by default as long as the necessary CRDs are available in the cluster.
CSI_ENABLE_VOLUME_GROUP_SNAPSHOT: "true"
# Enable cephfs kernel driver instead of ceph-fuse.
# If you disable the kernel client, your application may be disrupted during upgrade.
# See the upgrade guide: https://rook.io/docs/rook/latest/ceph-upgrade.html
Expand Down
19 changes: 16 additions & 3 deletions pkg/operator/ceph/csi/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ limitations under the License.
package csi

import (
"context"
"strconv"
"strings"
"time"

"github.com/rook/rook/pkg/operator/k8sutil"

"github.com/pkg/errors"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/version"
)
Expand Down Expand Up @@ -271,12 +273,12 @@ func (r *ReconcileCSI) setParams(ver *version.Info) error {
if len(nodes.Items) == 1 {
CSIParam.ProvisionerReplicas = 1
} else {
replicas := k8sutil.GetValue(r.opConfig.Parameters, "CSI_PROVISIONER_REPLICAS", "2")
r, err := strconv.ParseInt(replicas, 10, 32)
replicaStr := k8sutil.GetValue(r.opConfig.Parameters, "CSI_PROVISIONER_REPLICAS", "2")
replicas, err := strconv.ParseInt(replicaStr, 10, 32)
if err != nil {
logger.Errorf("failed to parse CSI_PROVISIONER_REPLICAS. Defaulting to %d. %v", defaultProvisionerReplicas, err)
} else {
CSIParam.ProvisionerReplicas = int32(r)
CSIParam.ProvisionerReplicas = int32(replicas)
}
}
} else {
Expand Down Expand Up @@ -317,5 +319,16 @@ func (r *ReconcileCSI) setParams(ver *version.Info) error {

CSIParam.DriverNamePrefix = k8sutil.GetValue(r.opConfig.Parameters, "CSI_DRIVER_NAME_PREFIX", r.opConfig.OperatorNamespace)

_, err = r.context.ApiExtensionsClient.ApiextensionsV1().CustomResourceDefinitions().Get(context.TODO(), "volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io", metav1.GetOptions{})
if err != nil && !kerrors.IsNotFound(err) {
return errors.Wrapf(err, "failed to get volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io CRD")
}
CSIParam.VolumeGroupSnapshotSupported = (err == nil)

CSIParam.EnableVolumeGroupSnapshot = true
if strings.EqualFold(k8sutil.GetValue(r.opConfig.Parameters, "CSI_ENABLE_VOLUME_GROUP_SNAPSHOT", "true"), "false") {
CSIParam.EnableVolumeGroupSnapshot = false
}

return nil
}
2 changes: 2 additions & 0 deletions pkg/operator/ceph/csi/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ type Param struct {
CephFSAttachRequired bool
RBDAttachRequired bool
NFSAttachRequired bool
VolumeGroupSnapshotSupported bool
EnableVolumeGroupSnapshot bool
LogLevel uint8
SidecarLogLevel uint8
CephFSLivenessMetricsPort uint16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ spec:
- "--leader-election-renew-deadline={{ .LeaderElectionRenewDeadline }}"
- "--leader-election-retry-period={{ .LeaderElectionRetryPeriod }}"
- "--extra-create-metadata=true"
{{ if .VolumeGroupSnapshotSupported }}
- "--enable-volume-group-snapshots={{ .EnableVolumeGroupSnapshot }}"
{{ end }}
env:
- name: ADDRESS
value: unix:///csi/csi-provisioner.sock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ spec:
- "--leader-election-renew-deadline={{ .LeaderElectionRenewDeadline }}"
- "--leader-election-retry-period={{ .LeaderElectionRetryPeriod }}"
- "--extra-create-metadata=true"
{{ if .VolumeGroupSnapshotSupported }}
- "--enable-volume-group-snapshots={{ .EnableVolumeGroupSnapshot }}"
{{ end }}
env:
- name: ADDRESS
value: unix:///csi/csi-provisioner.sock
Expand Down
26 changes: 24 additions & 2 deletions tests/framework/utils/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ import (
const (
// snapshotterVersion from which the snapshotcontroller and CRD will be
// installed
snapshotterVersion = "v5.0.1"
snapshotterVersion = "v7.0.1"
repoURL = "https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter"
rbacPath = "deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml"
controllerPath = "deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
// snapshot CRD path
// snapshot CRD path
snapshotClassCRDPath = "client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml"
volumeSnapshotContentsCRDPath = "client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml"
volumeSnapshotCRDPath = "client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml"
// volumegroupsnapshot CRD path
volumeGroupSnapshotClassCRDPath = "client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotclasses.yaml"
volumeGroupSnapshotContentsCRDPath = "client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml"
volumeGroupSnapshotCRDPath = "client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml"
)

// CheckSnapshotISReadyToUse checks snapshot is ready to use
Expand Down Expand Up @@ -143,6 +147,24 @@ func (k8sh *K8sHelper) snapshotCRD(action string) error {
if err != nil {
return err
}
vgsClassCRD := fmt.Sprintf("%s/%s/%s", repoURL, snapshotterVersion, volumeGroupSnapshotClassCRDPath)
_, err = k8sh.Kubectl(args(vgsClassCRD)...)
if err != nil {
return err
}

vgsContentsCRD := fmt.Sprintf("%s/%s/%s", repoURL, snapshotterVersion, volumeGroupSnapshotContentsCRDPath)
_, err = k8sh.Kubectl(args(vgsContentsCRD)...)
if err != nil {
return err
}

vgsCRD := fmt.Sprintf("%s/%s/%s", repoURL, snapshotterVersion, volumeGroupSnapshotCRDPath)
_, err = k8sh.Kubectl(args(vgsCRD)...)
if err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit 7ca738e

Please sign in to comment.