Skip to content

Commit 7e0bd8a

Browse files
authored
feat(snapshot): add snapshot support for LVM PV (#12)
Signed-off-by: Akhil Mohan <[email protected]>
1 parent b370f3c commit 7e0bd8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3457
-676
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ Features
7878
- [ ] Supports fsTypes: `ext4`, `btrfs`, `xfs`
7979
- [x] Volume metrics
8080
- [x] Topology
81-
- [ ] Snapshot
81+
- [x] Snapshot
8282
- [ ] Clone
83-
- [ ] Volume Resize
83+
- [x] Volume Resize
8484
- [ ] Backup/Restore
8585
- [ ] Ephemeral inline volume
86+
87+
### Limitation
88+
- Resize of volumes with snapshot is not supported

buildscripts/custom-boilerplate.go.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2020 The OpenEBS Authors
2+
Copyright 2021 The OpenEBS Authors
33

44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

buildscripts/generate-manifests.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ echo '
4747
cat deploy/yamls/local.openebs.io_lvmvolumes.yaml >> deploy/yamls/lvmvolume-crd.yaml
4848
rm deploy/yamls/local.openebs.io_lvmvolumes.yaml
4949

50+
echo '
51+
52+
##############################################
53+
########### ############
54+
########### LVMSnapshot CRD ############
55+
########### ############
56+
##############################################
57+
58+
# LVMSnapshot CRD is autogenerated via `make manifests` command.
59+
# Do the modification in the code and run the `make manifests` command
60+
# to generate the CRD definition' > deploy/yamls/lvmsnapshot-crd.yaml
61+
62+
cat deploy/yamls/local.openebs.io_lvmsnapshots.yaml >> deploy/yamls/lvmsnapshot-crd.yaml
63+
rm deploy/yamls/local.openebs.io_lvmsnapshots.yaml
64+
5065
## create the operator file using all the yamls
5166

5267
echo '# This manifest is autogenerated via `make manifests` command
@@ -63,6 +78,9 @@ cat deploy/yamls/namespace.yaml >> deploy/lvm-operator.yaml
6378
# Add LVMVolume v1alpha1 CRDs to the Operator yaml
6479
cat deploy/yamls/lvmvolume-crd.yaml >> deploy/lvm-operator.yaml
6580

81+
# Add LVMSnapshot v1alpha1 CRDs to the Operator yaml
82+
cat deploy/yamls/lvmsnapshot-crd.yaml >> deploy/lvm-operator.yaml
83+
6684
# Add the driver deployment to the Operator yaml
6785
cat deploy/yamls/lvm-driver.yaml >> deploy/lvm-operator.yaml
6886

changelog/unreleased/12-akhilerm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add support for create/delete snapshot for LVM localPV

deploy/lvm-operator.yaml

Lines changed: 649 additions & 323 deletions
Large diffs are not rendered by default.

deploy/sample/lvmsnapshot.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
kind: VolumeSnapshotClass
2+
apiVersion: snapshot.storage.k8s.io/v1
3+
metadata:
4+
name: lvm-localpv-snapclass
5+
annotations:
6+
snapshot.storage.kubernetes.io/is-default-class: "true"
7+
driver: local.csi.openebs.io
8+
deletionPolicy: Delete
9+
---
10+
apiVersion: snapshot.storage.k8s.io/v1
11+
kind: VolumeSnapshot
12+
metadata:
13+
name: lvm-localpv-snap
14+
spec:
15+
volumeSnapshotClassName: lvm-localpv-snapclass
16+
source:
17+
persistentVolumeClaimName: csi-lvmpvc

deploy/yamls/lvm-driver.yaml

Lines changed: 548 additions & 320 deletions
Large diffs are not rendered by default.

deploy/yamls/lvmsnapshot-crd.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
3+
##############################################
4+
########### ############
5+
########### LVMSnapshot CRD ############
6+
########### ############
7+
##############################################
8+
9+
# LVMSnapshot CRD is autogenerated via `make manifests` command.
10+
# Do the modification in the code and run the `make manifests` command
11+
# to generate the CRD definition
12+
13+
---
14+
apiVersion: apiextensions.k8s.io/v1beta1
15+
kind: CustomResourceDefinition
16+
metadata:
17+
annotations:
18+
controller-gen.kubebuilder.io/version: v0.2.8
19+
creationTimestamp: null
20+
name: lvmsnapshots.local.openebs.io
21+
spec:
22+
group: local.openebs.io
23+
names:
24+
kind: LVMSnapshot
25+
listKind: LVMSnapshotList
26+
plural: lvmsnapshots
27+
singular: lvmsnapshot
28+
preserveUnknownFields: false
29+
scope: Namespaced
30+
validation:
31+
openAPIV3Schema:
32+
description: LVMSnapshot represents an LVM Snapshot of the lvm volume
33+
properties:
34+
apiVersion:
35+
description: 'APIVersion defines the versioned schema of this representation
36+
of an object. Servers should convert recognized schemas to the latest
37+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
38+
type: string
39+
kind:
40+
description: 'Kind is a string value representing the REST resource this
41+
object represents. Servers may infer this from the endpoint the client
42+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
43+
type: string
44+
metadata:
45+
type: object
46+
spec:
47+
description: VolumeInfo defines LVM info
48+
properties:
49+
capacity:
50+
description: Capacity of the volume
51+
minLength: 1
52+
type: string
53+
ownerNodeID:
54+
description: OwnerNodeID is the Node ID where the volume group is present
55+
which is where the volume has been provisioned. OwnerNodeID can not
56+
be edited after the volume has been provisioned.
57+
minLength: 1
58+
type: string
59+
shared:
60+
description: Shared specifies whether the volume can be shared among
61+
multiple pods. If it is not set to "yes", then the LVM LocalPV Driver
62+
will not allow the volumes to be mounted by more than one pods.
63+
enum:
64+
- "yes"
65+
- "no"
66+
type: string
67+
volGroup:
68+
description: VolGroup specifies the name of the volume group where the
69+
volume has been created.
70+
minLength: 1
71+
type: string
72+
required:
73+
- capacity
74+
- ownerNodeID
75+
- volGroup
76+
type: object
77+
status:
78+
description: SnapStatus string that reflects if the snapshot was created
79+
successfully
80+
properties:
81+
state:
82+
type: string
83+
type: object
84+
required:
85+
- spec
86+
- status
87+
type: object
88+
version: v1alpha1
89+
versions:
90+
- name: v1alpha1
91+
served: true
92+
storage: true
93+
status:
94+
acceptedNames:
95+
kind: ""
96+
plural: ""
97+
conditions: []
98+
storedVersions: []

deploy/yamls/lvmvolume-crd.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ spec:
7575
minLength: 1
7676
type: string
7777
ownerNodeID:
78-
description: OwnerNodeID is the Node ID where the ZPOOL is running which
79-
is where the volume has been provisioned. OwnerNodeID can not be edited
80-
after the volume has been provisioned.
78+
description: OwnerNodeID is the Node ID where the volume group is present
79+
which is where the volume has been provisioned. OwnerNodeID can not
80+
be edited after the volume has been provisioned.
8181
minLength: 1
8282
type: string
8383
shared:
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Copyright 2021 The OpenEBS Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// +genclient
24+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
25+
// +resource:path=lvmsnapshot
26+
27+
// LVMSnapshot represents an LVM Snapshot of the lvm volume
28+
type LVMSnapshot struct {
29+
metav1.TypeMeta `json:",inline"`
30+
metav1.ObjectMeta `json:"metadata,omitempty"`
31+
32+
Spec VolumeInfo `json:"spec"`
33+
Status SnapStatus `json:"status"`
34+
}
35+
36+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
37+
// +resource:path=lvmsnapshots
38+
39+
// LVMSnapshotList is a list of LVMSnapshot resources
40+
type LVMSnapshotList struct {
41+
metav1.TypeMeta `json:",inline"`
42+
metav1.ListMeta `json:"metadata"`
43+
44+
Items []LVMSnapshot `json:"items"`
45+
}
46+
47+
// SnapStatus string that reflects if the snapshot was created successfully
48+
type SnapStatus struct {
49+
State string `json:"state,omitempty"`
50+
}

0 commit comments

Comments
 (0)