Skip to content

Commit 840b82e

Browse files
authored
Merge pull request ceph#274 from iPraveenParihar/dev-preview/rbd-snapshot-metadata
Alpha feature: RBD snapshot metadata sidecar
2 parents cde7377 + 884dc46 commit 840b82e

File tree

20 files changed

+737
-9
lines changed

20 files changed

+737
-9
lines changed

cmd/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
csiv1alpha1 "github.com/ceph/ceph-csi-operator/api/v1alpha1"
4444
"github.com/ceph/ceph-csi-operator/internal/controller"
4545
"github.com/ceph/ceph-csi-operator/internal/utils"
46+
sm "github.com/kubernetes-csi/external-snapshot-metadata/client/apis/snapshotmetadataservice/v1alpha1"
4647
//+kubebuilder:scaffold:imports
4748
)
4849

@@ -56,6 +57,7 @@ func init() {
5657

5758
utilruntime.Must(csiv1alpha1.AddToScheme(scheme))
5859
utilruntime.Must(csiv1.AddToScheme(scheme))
60+
utilruntime.Must(sm.AddToScheme(scheme))
5961
//+kubebuilder:scaffold:scheme
6062
}
6163

config/csi-rbac/rbd_ctrlplugin_cluster_role.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,9 @@ rules:
8181
- apiGroups: ["authentication.k8s.io"]
8282
resources: ["tokenreviews"]
8383
verbs: ["create"]
84+
- apiGroups: ["authorization.k8s.io"]
85+
resources: ["subjectaccessreviews"]
86+
verbs: ["create"]
87+
- apiGroups: ["cbt.storage.k8s.io"]
88+
resources: ["snapshotmetadataservices"]
89+
verbs: ["get", "list"]

config/rbac/role.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ rules:
3030
- patch
3131
- update
3232
- watch
33+
- apiGroups:
34+
- cbt.storage.k8s.io
35+
resources:
36+
- snapshotmetadataservices
37+
verbs:
38+
- get
39+
- list
40+
- watch
3341
- apiGroups:
3442
- csi.ceph.io
3543
resources:

deploy/all-in-one/install.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29122,6 +29122,14 @@ rules:
2912229122
- patch
2912329123
- update
2912429124
- watch
29125+
- apiGroups:
29126+
- cbt.storage.k8s.io
29127+
resources:
29128+
- snapshotmetadataservices
29129+
verbs:
29130+
- get
29131+
- list
29132+
- watch
2912529133
- apiGroups:
2912629134
- csi.ceph.io
2912729135
resources:
@@ -29626,6 +29634,19 @@ rules:
2962629634
- tokenreviews
2962729635
verbs:
2962829636
- create
29637+
- apiGroups:
29638+
- authorization.k8s.io
29639+
resources:
29640+
- subjectaccessreviews
29641+
verbs:
29642+
- create
29643+
- apiGroups:
29644+
- cbt.storage.k8s.io
29645+
resources:
29646+
- snapshotmetadataservices
29647+
verbs:
29648+
- get
29649+
- list
2962929650
---
2963029651
apiVersion: rbac.authorization.k8s.io/v1
2963129652
kind: ClusterRole

deploy/charts/ceph-csi-operator/templates/manager-rbac.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ rules:
3131
- patch
3232
- update
3333
- watch
34+
- apiGroups:
35+
- cbt.storage.k8s.io
36+
resources:
37+
- snapshotmetadataservices
38+
verbs:
39+
- get
40+
- list
41+
- watch
3442
- apiGroups:
3543
- csi.ceph.io
3644
resources:

deploy/charts/ceph-csi-operator/templates/rbd-ctrlplugin-cr-rbac.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,16 @@ rules:
212212
- tokenreviews
213213
verbs:
214214
- create
215+
- apiGroups:
216+
- authorization.k8s.io
217+
resources:
218+
- subjectaccessreviews
219+
verbs:
220+
- create
221+
- apiGroups:
222+
- cbt.storage.k8s.io
223+
resources:
224+
- snapshotmetadataservices
225+
verbs:
226+
- get
227+
- list

deploy/multifile/csi-rbac.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,19 @@ rules:
773773
- tokenreviews
774774
verbs:
775775
- create
776+
- apiGroups:
777+
- authorization.k8s.io
778+
resources:
779+
- subjectaccessreviews
780+
verbs:
781+
- create
782+
- apiGroups:
783+
- cbt.storage.k8s.io
784+
resources:
785+
- snapshotmetadataservices
786+
verbs:
787+
- get
788+
- list
776789
---
777790
apiVersion: rbac.authorization.k8s.io/v1
778791
kind: ClusterRole

deploy/multifile/operator.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,14 @@ rules:
288288
- patch
289289
- update
290290
- watch
291+
- apiGroups:
292+
- cbt.storage.k8s.io
293+
resources:
294+
- snapshotmetadataservices
295+
verbs:
296+
- get
297+
- list
298+
- watch
291299
- apiGroups:
292300
- csi.ceph.io
293301
resources:
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Guide for RBD Deployment with CSI Snapshot-Metadata Sidecar
2+
3+
> ⚠️ **Warning - Alpha Feature**:
4+
> This feature is currently in **alpha** and is subject to change in future releases.
5+
> This feature should only be used for testing and evaluation purposes.
6+
7+
[KEP-3314](https://github.com/kubernetes/enhancements/tree/master/keps/sig-storage/3314-csi-changed-block-tracking)
8+
introduces new CSI APIs to identify changed blocks between snapshots of CSI volumes.
9+
These APIs enable efficient and incremental backups by allowing backup applications
10+
to retrieve only the data that has changed.
11+
12+
To support this feature, Ceph-CSI should include an `external-snapshot-metadata`
13+
sidecar in the RBD controller plugin.
14+
15+
This document outlines how the Ceph-CSI Operator manages the deployment
16+
of the RBD controller plugin with the `external-snapshot-metadata` sidecar.
17+
18+
(_Note: Only the RBD driver supports the SnapshotMetadata capability._)
19+
20+
## Admin Responsibilities
21+
22+
Users need to perform the following manual setup:
23+
24+
1. Install the [SnapshotMetadataService CRD](https://github.com/kubernetes-csi/external-snapshot-metadata/blob/v0.1.0/client/config/crd/cbt.storage.k8s.io_snapshotmetadataservices.yaml)
25+
26+
```bash
27+
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshot-metadata/refs/tags/v0.1.0/client/config/crd/cbt.storage.k8s.io_snapshotmetadataservices.yaml
28+
```
29+
30+
2. Create a Service to expose the RBD driver pod
31+
32+
Create a service to enable communication with the RBD controller plugin:
33+
34+
```yaml
35+
apiVersion: v1
36+
kind: Service
37+
metadata:
38+
name: <service-name>
39+
namespace: <driver-namespace>
40+
spec:
41+
ports:
42+
- name: snapshot-metadata-port
43+
port: <service-port>
44+
protocol: TCP
45+
targetPort: 50051 # should be the same as the sidecar uses this port for its gRPC server
46+
selector:
47+
app: <driver-name>-ctrlplugin # RBD controller plugin pod label
48+
type: ClusterIP
49+
```
50+
51+
> **Note:**
52+
> - Replace `<service-name>` with your desired service name (e.g., `rbd-csi-ceph-com-metadata`)
53+
> - Replace `<driver-namespace>` with the namespace where your RBD driver is deployed
54+
> - Replace `<service-port>` with your desired service port (e.g., `6443`)
55+
> - Replace `<driver-name>` with your RBD driver name (e.g., `rbd.csi.ceph.com`)
56+
57+
3. Provision TLS certificates and create a TLS secret
58+
59+
Generate TLS certificates using your preferred method (self-signed, cert-manager, etc).
60+
The certificates must be valid for the service domain created in step 2: `<service-name>.<driver-namespace>`
61+
62+
Create a TLS secret with the generated certificates:
63+
64+
```bash
65+
kubectl create secret tls <driver-name> \
66+
--namespace=<driver-namespace> \
67+
--cert=server-cert.pem \
68+
--key=server-key.pem
69+
```
70+
71+
> **Note:**
72+
> - Replace `<driver-name>` with your RBD driver name (e.g., `rbd.csi.ceph.com`)
73+
> - Replace `<driver-namespace>` with the namespace where your RBD driver is deployed
74+
> - Ensure certificates are valid for the domain: `<service-name>.<driver-namespace>` (using the service name from step 2)
75+
76+
4. Create a SnapshotMetadataService CR for the RBD driver that will deploy the `external-snapshot-metadata` sidecar.
77+
The name of this CR must match the RBD driver CR name.
78+
79+
**Example:**
80+
81+
```yaml
82+
apiVersion: cbt.storage.k8s.io/v1alpha1
83+
kind: SnapshotMetadataService
84+
metadata:
85+
name: <driver-name>
86+
spec:
87+
address: <service-name>.<driver-namespace>:<service-port>
88+
audience: <driver-name>
89+
caCert: <ca-bundle>
90+
```
91+
92+
> **Note:**
93+
> - `address`: Should point to the service created in step 2, replace `<service-name>`, `<driver-namespace>`, and `<service-port>` with your actual values from step 2
94+
> - `audience`: Recommended to use the CSI driver name for consistency
95+
> - `caCert`: Base64-encoded CA certificate bundle
96+
97+
5. Provide the TLS secret required for the `external-snapshot-metadata` sidecar as a volume mount in the RBD driver CR.
98+
99+
**Example:**
100+
101+
```yaml
102+
apiVersion: csi.ceph.io/v1
103+
kind: Driver
104+
metadata:
105+
name: <driver-name>
106+
namespace: <driver-namespace>
107+
spec:
108+
# ... other fields ...
109+
controllerPlugin:
110+
volumes:
111+
- mount:
112+
mountPath: /tmp/certificates # Must be /tmp/certificates - required by sidecar
113+
name: tls-key
114+
volume:
115+
name: tls-key # Must be "tls-key"
116+
secret:
117+
secretName: snapshot-metadata-tls # The TLS secret name
118+
```
119+
120+
> **Note:**
121+
> - **mountPath must be `/tmp/certificates`**: This path is required by the snapshot metadata sidecar to locate TLS certificates.
122+
> - **Volume name and mount name must be `tls-key`**: The operator specifically filters for volumes with this exact name to mount in the snapshot-metadata sidecar container.
123+
> - Replace `<driver-name>` with your RBD driver name (e.g., `rbd.csi.ceph.com`)
124+
> - Replace `<driver-namespace>` with the namespace where your RBD driver is deployed
125+
126+
## Ceph-CSI Operator Responsibilities
127+
128+
The operator will perform the following actions for the RBD controller plugin deployment:
129+
130+
- Check for the existence of the SnapshotMetadataService CR (name must be the same as the RBD driver CR)
131+
- Check for the volume of type SecretVolumeSource (name must be the same as the RBD driver CR)
132+
133+
> ⚠️ **Note**: If the SnapshotMetadataService CR is created after adding the volume configuration
134+
> in the RBD driver CR, the ceph-csi-operator pod needs to be restarted manually.

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.24.0
55
require (
66
github.com/ceph/ceph-csi-operator/api v0.0.0-00010101000000-000000000000
77
github.com/go-logr/logr v1.4.3
8+
github.com/kubernetes-csi/external-snapshot-metadata/client v0.0.0-20250716030224-c97af6ded787
89
github.com/onsi/ginkgo/v2 v2.23.4
910
github.com/onsi/gomega v1.38.0
1011
k8s.io/api v0.33.3

0 commit comments

Comments
 (0)