Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add volume group replication controller code #610

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
VolumeGroupReplicationNameAnnotation = "replication.storage.openshift.io/volume-group-replication-name"
)

// VolumeGroupReplicationSpec defines the desired state of VolumeGroupReplication
type VolumeGroupReplicationSpec struct {
// volumeGroupReplicationClassName is the volumeGroupReplicationClass name for this VolumeGroupReplication resource
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationClassName is immutable"
VolumeGroupReplicationClassName string `json:"volumeGroupReplicationClassName"`

// volumeReplicationClassName is the volumeReplicationClass name for VolumeReplication object
// volumeReplicationClassName is the volumeReplicationClass name for the VolumeReplication object
// created for this volumeGroupReplication
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumReplicationClassName is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeReplicationClassName is immutable"
VolumeReplicationClassName string `json:"volumeReplicationClassName"`

// Name of the VolumeReplication object created for this volumeGroupReplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
VolumeGroupReplicationContentNameAnnotation = "replication.storage.openshift.io/volumegroupreplication-content-name"
)

// VolumeGroupReplicationContentSpec defines the desired state of VolumeGroupReplicationContent
type VolumeGroupReplicationContentSpec struct {
// VolumeGroupreplicationRef specifies the VolumeGroupReplication object to which this
Expand Down Expand Up @@ -52,9 +56,8 @@ type VolumeGroupReplicationContentSpec struct {
// +optional
VolumeGroupReplicationClassName string `json:"volumeGroupReplicationClassName"`

// Source specifies whether the snapshot is (or should be) dynamically provisioned
// Source specifies whether the volume is (or should be) dynamically provisioned
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that should be "volume group"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, becuase we are storing the volume handles in the source of the VGRContent. So, I think it should be "volumes" only.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, righ. Can you include an example of a VGRContent in the docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, somehow I missed it (though I had it in the back of my mind that I need to add that)

// or already exists, and just requires a Kubernetes object representation.
// This field is immutable after creation.
// Required.
Source VolumeGroupReplicationContentSource `json:"source"`
}
Expand All @@ -68,7 +71,7 @@ type VolumeGroupReplicationContentSource struct {

// VolumeGroupReplicationContentStatus defines the status of VolumeGroupReplicationContent
type VolumeGroupReplicationContentStatus struct {
// PersistentVolumeRefList is the list of of PV for the group replication
// PersistentVolumeRefList is the list of PV for the group replication
// The maximum number of allowed PV in the group is 100.
// +optional
PersistentVolumeRefList []corev1.LocalObjectReference `json:"persistentVolumeRefList,omitempty"`
Expand Down
6 changes: 4 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ func main() {
os.Exit(1)
}
if err = (&replicationController.VolumeGroupReplicationContentReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Connpool: connPool,
Timeout: defaultTimeout,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "VolumeGroupReplicationContent")
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ spec:
type: string
source:
description: |-
Source specifies whether the snapshot is (or should be) dynamically provisioned
Source specifies whether the volume is (or should be) dynamically provisioned
or already exists, and just requires a Kubernetes object representation.
This field is immutable after creation.
Required.
properties:
volumeHandles:
Expand Down Expand Up @@ -146,7 +145,7 @@ spec:
properties:
persistentVolumeRefList:
description: |-
PersistentVolumeRefList is the list of of PV for the group replication
PersistentVolumeRefList is the list of PV for the group replication
The maximum number of allowed PV in the group is 100.
items:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ spec:
- message: volumeGroupReplicationContentName is immutable
rule: self == oldSelf
volumeReplicationClassName:
description: volumeReplicationClassName is the volumeReplicationClass
name for VolumeReplication object
description: |-
volumeReplicationClassName is the volumeReplicationClass name for the VolumeReplication object
created for this volumeGroupReplication
type: string
x-kubernetes-validations:
- message: volumReplicationClassName is immutable
- message: volumeReplicationClassName is immutable
rule: self == oldSelf
volumeReplicationName:
description: Name of the VolumeReplication object created for this
Expand Down
35 changes: 31 additions & 4 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ rules:
- ""
resources:
- namespaces
- persistentvolumes
- pods
verbs:
- get
Expand All @@ -30,6 +29,15 @@ rules:
- persistentvolumeclaims/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- persistentvolumes
verbs:
- get
- list
- update
- watch
- apiGroups:
- coordination.k8s.io
resources:
Expand Down Expand Up @@ -82,11 +90,19 @@ rules:
- get
- patch
- update
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationclasses
- volumereplicationclasses
verbs:
- get
- list
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationcontents
- volumegroupreplications
verbs:
- create
- delete
Expand All @@ -101,7 +117,6 @@ rules:
- volumegroupreplicationcontents/finalizers
- volumegroupreplications/finalizers
- volumereplications/finalizers
- volumereplications/status
verbs:
- update
- apiGroups:
Expand All @@ -116,20 +131,32 @@ rules:
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplicationclasses
- volumegroupreplications
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications/status
verbs:
- get
- list
- update
- apiGroups:
- storage.k8s.io
resources:
Expand Down
12 changes: 6 additions & 6 deletions deploy/controller/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1414,9 +1414,8 @@ spec:
type: string
source:
description: |-
Source specifies whether the snapshot is (or should be) dynamically provisioned
Source specifies whether the volume is (or should be) dynamically provisioned
or already exists, and just requires a Kubernetes object representation.
This field is immutable after creation.
Required.
properties:
volumeHandles:
Expand Down Expand Up @@ -1508,7 +1507,7 @@ spec:
properties:
persistentVolumeRefList:
description: |-
PersistentVolumeRefList is the list of of PV for the group replication
PersistentVolumeRefList is the list of PV for the group replication
The maximum number of allowed PV in the group is 100.
items:
description: |-
Expand Down Expand Up @@ -1666,11 +1665,12 @@ spec:
- message: volumeGroupReplicationContentName is immutable
rule: self == oldSelf
volumeReplicationClassName:
description: volumeReplicationClassName is the volumeReplicationClass
name for VolumeReplication object
description: |-
volumeReplicationClassName is the volumeReplicationClass name for the VolumeReplication object
created for this volumeGroupReplication
type: string
x-kubernetes-validations:
- message: volumReplicationClassName is immutable
- message: volumeReplicationClassName is immutable
rule: self == oldSelf
volumeReplicationName:
description: Name of the VolumeReplication object created for this
Expand Down
35 changes: 31 additions & 4 deletions deploy/controller/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ rules:
- ""
resources:
- namespaces
- persistentvolumes
- pods
verbs:
- get
Expand All @@ -123,6 +122,15 @@ rules:
- persistentvolumeclaims/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- persistentvolumes
verbs:
- get
- list
- update
- watch
- apiGroups:
- coordination.k8s.io
resources:
Expand Down Expand Up @@ -175,11 +183,19 @@ rules:
- get
- patch
- update
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationclasses
- volumereplicationclasses
verbs:
- get
- list
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationcontents
- volumegroupreplications
verbs:
- create
- delete
Expand All @@ -194,7 +210,6 @@ rules:
- volumegroupreplicationcontents/finalizers
- volumegroupreplications/finalizers
- volumereplications/finalizers
- volumereplications/status
verbs:
- update
- apiGroups:
Expand All @@ -209,20 +224,32 @@ rules:
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplicationclasses
- volumegroupreplications
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications/status
verbs:
- get
- list
- update
- apiGroups:
- storage.k8s.io
resources:
Expand Down
37 changes: 37 additions & 0 deletions docs/volumegroupreplication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# VolumeGroupReplication

VolumeGroupReplication is a namespaced resource that contains references to storage object to be grouped and replicated, VolumeGroupReplicationClass corresponding to the driver providing replication, VolumeGroupContent and VolumeReplication CRs.

`volumeGroupReplicationClassName` is the name of the class providing group replication.

`volumeReplicationClassName` is the name of the class providing the replication for volumeReplication CR.

`volumeReplicationName` is the name of the volumeReplication CR created by this volumeGroupReplication CR

`volumeGroupReplicationContentName` is the name of the volumeGroupReplicationConten CR created by this volumeGroupReplication CR.

`replicationState` is the state of the volume being referenced. Possible values are `primary`, `secondary` and `resync`.

- `primary` denotes that the volume is primary
- `secondary` denotes that the volume is secondary
- `resync` denotes that the volume needs to be resynced

`source` contains the source of the volumeGroupReplication i.e, the selectors to match the PVC/PVs to be replicated.

- `selector` is a label selector to filter the pvcs that are to be included in the group replication

```yaml
apiVersion: replication.storage.openshift.io/v1alpha1
kind: VolumeGroupReplication
metadata:
name: volumegroupreplication-sample
namespace: default
spec:
volumeReplicationClassName: volumereplicationclass-sample
volumeGroupReplicationClassName: volumegroupreplicationclass-sample
replicationState: primary
source:
selector:
matchLabels:
group: replication
```
24 changes: 24 additions & 0 deletions docs/volumegroupreplicationclass.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# VolumeGroupReplicationClass

VolumeGroupReplicationClass is a cluster scoped resource that contains driver related configuration parameters for volume group replication.

`provisioner` is name of the storage provisioner.

`parameters` contains key-value pairs that are passed down to the driver. Users can add their own key-value pairs. Keys with `replication.storage.openshift.io/` prefix are reserved by operator and not passed down to the driver.

## Reserved parameter keys

- `replication.storage.openshift.io/group-replication-secret-name`
- `replication.storage.openshift.io/group-replication-secret-namespace`

```yaml
apiVersion: replication.storage.openshift.io/v1alpha1
kind: VolumeGroupReplicationClass
metadata:
name: volumegroupreplicationclass-sample
spec:
provisioner: example.provisioner.io
parameters:
replication.storage.openshift.io/group-replication-secret-name: secret-name
replication.storage.openshift.io/group-replication-secret-namespace: secret-namespace
```
Loading
Loading