Skip to content

Commit

Permalink
use schedule instead of VolumeReplicationClass
Browse files Browse the repository at this point in the history
VolumeReplicationClass field in VolumeReplicationGroup is
nothing but a string. Instead of that, use a schedule which
is then used in combination with the storage driver for the
pvc (obtained from storageclass) by the VolumeReplicationGroup
to determine the appropriate VolumeReplicationClass to use.

HUB/DRPC (Previously AVR):
- modify DRPolicy to include schedule along with DR prepared
  clusters
- Make DRPC (previously AVR) refer to the DRPolicy schedule
  while creating VolumeReplicationGroup and use that as the
  schedule for VolumeReplicationGroup.

Managed Cluster:
- While reconciling VolumeReplicationGroup, for each of the
  PVC obtained via label selection, do this
    - storagedriver = StorageDriver(StorageClass(pvc))
    - Get All the VolumeReplicationClasses in the cluster
    - For each VolumeReplicationClass (chosen via label selector)
        if (replicationdriver == storagedriver and
             replicationSchedule == vrg.Spec.Schedule)
             chosenReplicationClass = VolumeReplicationClass

Signed-off-by: Raghavendra M <raghavendra@redhat.com>
  • Loading branch information
raghavendrabhat authored and ShyamsundarR committed Aug 11, 2021
1 parent e89a496 commit e61df22
Show file tree
Hide file tree
Showing 17 changed files with 791 additions and 87 deletions.
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ linters:
- goerr113 # TODO: Need to introduce error definition and bring this back
- goheader # TODO: Introduce back post fixing linter errors
- gci
- interfacer # interfacer linter is archived and deprecated (https://github.com/mvdan/interfacer)
12 changes: 12 additions & 0 deletions api/v1alpha1/drpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ type DRPolicySpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// scheduling Interval for replicating Persistent Volume
// data to a peer cluster. Interval is typically in the
// form <num><m,h,d>. Here <num> is a number, 'm' means
// minutes, 'h' means hours and 'd' stands for days.
SchedulingInterval string `json:"schedulingInterval"`

// Members of the DRPolicy set
ClusterNames []string `json:"clusterNames"`

// Label selector to identify all the VolumeReplicationClasses.
// This selector is assumed to be the same for all subscriptions that
// need DR protection. It will be passed in to the VRG when it is created
//+optional
ReplicationClassSelector metav1.LabelSelector `json:"replicationClassSelector,omitempty"`
}

// DRPolicyStatus defines the observed state of DRPolicy
Expand Down
26 changes: 16 additions & 10 deletions api/v1alpha1/volumereplicationgroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Important: Run "make" to regenerate code after modifying this file

// ReplicationState represents the replication operations to be performed on the volume
type ReplicationState string

Expand Down Expand Up @@ -47,9 +49,9 @@ const (

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// VolumeReplicationGroup (VRG) spec declares the desired replication class
// and replication state of all the PVCs identified via the given PVC label
// selector. For each such PVC, the VRG will do the following:
// VolumeReplicationGroup (VRG) spec declares the desired schedule for data
// replication and replication state of all PVCs identified via the given
// PVC label selector. For each such PVC, the VRG will do the following:
// - Create a VolumeReplication (VR) CR to enable storage level replication
// of volume data and set the desired replication state (primary, secondary,
// etc).
Expand All @@ -60,15 +62,21 @@ const (
// - Manage the lifecycle of VR CR and S3 data according to CUD operations on
// the PVC and the VRG CR.
type VolumeReplicationGroupSpec struct {
// Important: Run "make" to regenerate code after modifying this file

// Label selector to identify all the PVCs that are in this group
// that needs to be replicated to the peer cluster.
PVCSelector metav1.LabelSelector `json:"pvcSelector"`

// ReplicationClass of all volumes in this replication group;
// this value is propagated to children VolumeReplication CRs
VolumeReplicationClass string `json:"volumeReplicationClass"`
// Label selector to identify the VolumeReplicationClass resources
// that are scanned to select an appropriate VolumeReplicationClass
// for the VolumeReplication resource.
//+optional
ReplicationClassSelector metav1.LabelSelector `json:"replicationClassSelector,omitempty"`

// scheduling Interval for replicating Persistent Volume
// data to a peer cluster. Interval is typically in the
// form <num><m,h,d>. Here <num> is a number, 'm' means
// minutes, 'h' means hours and 'd' stands for days.
SchedulingInterval string `json:"schedulingInterval"`

// Desired state of all volumes [primary or secondary] in this replication group;
// this value is propagated to children VolumeReplication CRs
Expand All @@ -85,7 +93,6 @@ type VolumeReplicationGroupSpec struct {
// is replicated by a different mechanism; this mode of operation may be
// referred to as backup-less mode.
S3Endpoint string `json:"s3Endpoint,omitempty"`

// S3 Region: https://docs.aws.amazon.com/general/latest/gr/rande.html
S3Region string `json:"s3Region,omitempty"`

Expand All @@ -109,7 +116,6 @@ type ProtectedPVCMap map[string]*ProtectedPVC

// VolumeReplicationGroupStatus defines the observed state of VolumeReplicationGroup
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
type VolumeReplicationGroupStatus struct {
State State `json:"state,omitempty"`

Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions config/crd/bases/ramendr.openshift.io_drpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,61 @@ spec:
items:
type: string
type: array
replicationClassSelector:
description: Label selector to identify all the VolumeReplicationClasses.
This selector is assumed to be the same for all subscriptions that
need DR protection. It will be passed in to the VRG when it is created
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
items:
description: A label selector requirement is a selector that
contains values, a key, and an operator that relates the key
and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship to
a set of values. Valid operators are In, NotIn, Exists
and DoesNotExist.
type: string
values:
description: values is an array of string values. If the
operator is In or NotIn, the values array must be non-empty.
If the operator is Exists or DoesNotExist, the values
array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
type: object
type: object
schedulingInterval:
description: scheduling Interval for replicating Persistent Volume
data to a peer cluster. Interval is typically in the form <num><m,h,d>.
Here <num> is a number, 'm' means minutes, 'h' means hours and 'd'
stands for days.
type: string
required:
- clusterNames
- schedulingInterval
type: object
status:
description: 'DRPolicyStatus defines the observed state of DRPolicy INSERT
Expand Down
85 changes: 66 additions & 19 deletions config/crd/bases/ramendr.openshift.io_volumereplicationgroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ spec:
metadata:
type: object
spec:
description: "VolumeReplicationGroup (VRG) spec declares the desired replication
class and replication state of all the PVCs identified via the given
PVC label selector. For each such PVC, the VRG will do the following:
\t- Create a VolumeReplication (VR) CR to enable storage level replication
\t of volume data and set the desired replication state (primary, secondary,
\ etc). - Take the corresponding PV metadata in Kubernetes etcd and
deposit it in the S3 store. The url, access key and access id required
to access the S3 store is specified via environment variables of
the VRG operator POD, which is obtained from a secret resource. -
Manage the lifecycle of VR CR and S3 data according to CUD operations
on the PVC and the VRG CR."
description: "VolumeReplicationGroup (VRG) spec declares the desired schedule
for data replication and replication state of all PVCs identified via
the given PVC label selector. For each such PVC, the VRG will do the
following: \t- Create a VolumeReplication (VR) CR to enable storage
level replication \t of volume data and set the desired replication
state (primary, secondary, etc). - Take the corresponding PV metadata
in Kubernetes etcd and deposit it in the S3 store. The url, access
key and access id required to access the S3 store is specified via
environment variables of the VRG operator POD, which is obtained
from a secret resource. - Manage the lifecycle of VR CR and S3 data
according to CUD operations on the PVC and the VRG CR."
properties:
pvcSelector:
description: Label selector to identify all the PVCs that are in this
Expand Down Expand Up @@ -94,6 +94,52 @@ spec:
are ANDed.
type: object
type: object
replicationClassSelector:
description: Label selector to identify the VolumeReplicationClass
resources that are scanned to select an appropriate VolumeReplicationClass
for the VolumeReplication resource.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
items:
description: A label selector requirement is a selector that
contains values, a key, and an operator that relates the key
and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship to
a set of values. Valid operators are In, NotIn, Exists
and DoesNotExist.
type: string
values:
description: values is an array of string values. If the
operator is In or NotIn, the values array must be non-empty.
If the operator is Exists or DoesNotExist, the values
array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
type: object
type: object
replicationState:
description: Desired state of all volumes [primary or secondary] in
this replication group; this value is propagated to children VolumeReplication
Expand Down Expand Up @@ -121,20 +167,21 @@ spec:
key set using the keys: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. The
secret should be present in the same namespace as the VRG'
type: string
volumeReplicationClass:
description: ReplicationClass of all volumes in this replication group;
this value is propagated to children VolumeReplication CRs
schedulingInterval:
description: scheduling Interval for replicating Persistent Volume
data to a peer cluster. Interval is typically in the form <num><m,h,d>.
Here <num> is a number, 'm' means minutes, 'h' means hours and 'd'
stands for days.
type: string
required:
- pvcSelector
- replicationState
- volumeReplicationClass
- schedulingInterval
type: object
status:
description: 'VolumeReplicationGroupStatus defines the observed state
of VolumeReplicationGroup INSERT ADDITIONAL STATUS FIELD - define observed
state of cluster Important: Run "make" to regenerate code after modifying
this file'
description: VolumeReplicationGroupStatus defines the observed state of
VolumeReplicationGroup INSERT ADDITIONAL STATUS FIELD - define observed
state of cluster
properties:
conditions:
description: Conditions are the list of conditions and their status.
Expand Down
17 changes: 17 additions & 0 deletions config/dr_cluster/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,20 @@ rules:
- patch
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplicationclasses
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
17 changes: 17 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ rules:
- get
- patch
- update
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplicationclasses
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
Expand All @@ -146,6 +156,13 @@ rules:
- patch
- update
- watch
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
- apiGroups:
- view.open-cluster-management.io
resources:
Expand Down
4 changes: 4 additions & 0 deletions config/samples/ramendr_v1alpha1_drpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ kind: DRPolicy
metadata:
name: drpolicy-sample
spec:
schedulingInterval: "1h" # hourly
replicationClassSelector:
matchLabels:
class: ramen
clusterNames:
- east
- west
5 changes: 4 additions & 1 deletion config/samples/ramendr_v1alpha1_volumereplicationgroup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ spec:
pvcSelector:
matchLabels:
any-pvc-label: value
volumeReplicationClass: "storage-replication-class"
schedulingInterval: "1h"
replicationState: "Primary"
replicationSelector:
matchLabels:
class: ramen
s3Endpoint: "path/to/s3Endpoint"
s3Region: "unknown"
s3SecretName: secret-name-with-s3-credentials

0 comments on commit e61df22

Please sign in to comment.