Chapter 9. Multicloud Object Gateway bucket replication
Data replication from one Multicloud Object Gateway (MCG) bucket to another MCG bucket provides higher resiliency and better collaboration options. These buckets can be either data buckets or namespace buckets backed by any supported storage solution (S3, Azure, etc.).
A replication policy is composed of a list of replication rules. Each rule defines the destination bucket, and can specify a filter based on an object key prefix. Configuring a complementing replication policy on the second bucket results in bidirectional replication.
Prerequisites
- A running OpenShift Data Foundation Platform.
- Access to the Multicloud Object Gateway, see link:Accessing the Multicloud Object Gateway with your applications.
Download the Multicloud Object Gateway (MCG) command-line interface:
# subscription-manager repos --enable=rh-odf-4-for-rhel-8-x86_64-rpms # yum install mcg
ImportantSpecify the appropriate architecture for enabling the repositories using the subscription manager. For instance, in case of IBM Power use the following command:
# subscription-manager repos --enable=rh-odf-4-for-rhel-8-ppc64le-rpms
Alternatively, you can install the
mcg
package from the OpenShift Data Foundation RPMs found here https://access.redhat.com/downloads/content/547/ver=4/rhel---8/4/x86_64/packagesImportantChoose the correct Product Variant according to your architecture.
NoteCertain MCG features are only available in certain MCG versions, and the appropriate MCG CLI tool version must be used to fully utilize MCG’s features.
To replicate a bucket, see Replicating a bucket to another bucket.
To set a bucket class replication policy, see Setting a bucket class replication policy.
9.1. Replicating a bucket to another bucket
You can set the bucket replication policy in two ways:
9.1.1. Replicating a bucket to another bucket using the MCG command-line interface
Applications that require a Multicloud Object Gateway (MCG) bucket to have a specific replication policy can create an Object Bucket Claim (OBC) and define the replication policy
parameter in a JSON file.
Procedure
From the MCG command-line interface, run the following command to create an OBC with a specific replication policy:
noobaa obc create <bucket-claim-name> -n openshift-storage --replication-policy /path/to/json-file.json
<bucket-claim-name>
- Specify the name of the bucket claim.
/path/to/json-file.json
Is the path to a JSON file which defines the replication policy.
Example JSON file:
[{ "rule_id": "rule-1", "destination_bucket": "first.bucket", "filter": {"prefix": "repl"}}]
"prefix"
-
Is optional. It is the prefix of the object keys that should be replicated, and you can even leave it empty, for example,
{"prefix": ""}
.
Example 9.1. Example
noobaa obc create my-bucket-claim -n openshift-storage --replication-policy /path/to/json-file.json
9.1.2. Replicating a bucket to another bucket using a YAML
Applications that require a Multicloud Object Gateway (MCG) data bucket to have a specific replication policy can create an Object Bucket Claim (OBC) and add the spec.additionalConfig.replication-policy
parameter to the OBC.
Procedure
Apply the following YAML:
apiVersion: objectbucket.io/v1alpha1 kind: ObjectBucketClaim metadata: name: <desired-bucket-claim> namespace: <desired-namespace> spec: generateBucketName: <desired-bucket-name> storageClassName: openshift-storage.noobaa.io additionalConfig: replication-policy: [{ "rule_id": "<rule id>", "destination_bucket": "first.bucket", "filter": {"prefix": "<object name prefix>"}}]
<desired-bucket-claim>
- Specify the name of the bucket claim.
<desired-namespace>
- Specify the namespace.
<desired-bucket-name>
- Specify the prefix of the bucket name.
"rule_id"
-
Specify the ID number of the rule, for example,
{"rule_id": "rule-1"}
. "destination_bucket"
-
Specify the name of the destination bucket, for example,
{"destination_bucket": "first.bucket"}
. "prefix"
-
Is optional. It is the prefix of the object keys that should be replicated, and you can even leave it empty, for example,
{"prefix": ""}
.
Additional information
- For more information about OBCs, see Object Bucket Claim.
9.2. Setting a bucket class replication policy
It is possible to set up a replication policy that automatically applies to all the buckets created under a certain bucket class. You can do this in two ways:
9.2.1. Setting a bucket class replication policy using the MCG command-line interface
Applications that require a Multicloud Object Gateway (MCG) bucket class to have a specific replication policy can create a bucketclass
and define the replication-policy
parameter in a JSON file.
It is possible to set a bucket class replication policy for two types of bucket classes:
- Placement
- Namespace
Procedure
From the MCG command-line interface, run the following command:
noobaa -n openshift-storage bucketclass create placement-bucketclass <bucketclass-name> --backingstores <backingstores> --replication-policy=/path/to/json-file.json
<bucketclass-name>
- Specify the name of the bucket class.
<backingstores>
- Specify the name of a backingstore. It is possible to pass several backingstores separated by commas.
/path/to/json-file.json
Is the path to a JSON file which defines the replication policy.
Example JSON file:
[{ "rule_id": "rule-1", "destination_bucket": "first.bucket", "filter": {"prefix": "repl"}}]
"prefix"
-
Is optional. It is the prefix of the object keys that should be replicated, and you can even leave it empty, for example,
{"prefix": ""}
.
Example 9.2. Example
noobaa -n openshift-storage bucketclass create placement-bucketclass bc --backingstores azure-blob-ns --replication-policy=/path/to/json-file.json
This example creates a placement bucket class with a specific replication policy defined in the JSON file.
9.2.2. Setting a bucket class replication policy using a YAML
Applications that require a Multicloud Object Gateway (MCG) bucket class to have a specific replication policy can create a bucket class using the spec.replicationPolicy
field.
Procedure
Apply the following YAML:
apiVersion: noobaa.io/v1alpha1 kind: BucketClass metadata: labels: app: <desired-app-label> name: <desired-bucketclass-name> namespace: <desired-namespace> spec: placementPolicy: tiers: - backingstores: - <backingstore> placement: Spread replicationPolicy: [{ "rule_id": "<rule id>", "destination_bucket": "first.bucket", "filter": {"prefix": "<object name prefix>"}}]
This YAML is an example that creates a placement bucket class. Each Object bucket claim (OBC) object that is uploaded to the bucket is filtered based on the prefix and is replicated to
first.bucket
.<desired-app-label>
- Specify a label for the app.
<desired-bucketclass-name>
- Specify the bucket class name.
<desired-namespace>
- Specify the namespace in which the bucket class gets created.
<backingstore>
- Specify the name of a backingstore. It is possible to pass several backingstores.
"rule_id"
-
Specify the ID number of the rule, for example,
`{"rule_id": "rule-1"}
. "destination_bucket"
-
Specify the name of the destination bucket, for example,
{"destination_bucket": "first.bucket"}
. "prefix"
-
Is optional. It is the prefix of the object keys that should be replicated, and you can even leave it empty, for example,
{"prefix": ""}
.