Updated on 2025-04-30 GMT+08:00

Replication Policies

Creating a Replication Policy

  1. Log in to the SWR console. In the upper left corner, switch to your region. Click a repository name to go to its details page.
  2. In the navigation pane, choose Image Replication > Replication Policies.
  3. Click Add Replication Policy in the upper right corner.
  4. In the displayed dialog box, configure the parameters.

    Table 1 Parameter description

    Parameter

    Description

    Example

    Name

    Replication policy name.

    SyncRule

    Replication Direction

    • Push to target registry: Push images to the target registry.
    • Pull from target registry: Pull images from the target registry.

    Push to target registry

    Target Registry

    Select the target registry added in Adding a Target Registry.

    -

    Destination Namespace (for push to target registry)

    Namespace that images will be pushed to. A namespace may be called a project on other clouds. If you omit it here, images will be pushed to the same namespace as in the source registry by default. If no such a namespace exists at the destination, replication may fail.

    library1

    Destination Namespace (for pull from target registry)

    Namespace that images will be pulled to. A namespace may be called a project on other clouds. If you omit it here, images will be pulled to the same namespace as in the source registry by default. If no such a namespace exists at the destination, replication may fail.

    library1

    Source Resource Filter (for push to target registry)

    Namespace: Select a namespace.

    Image: You can use a regular expression to specify images. Alternatively, you can click to select images.

    The regular expression can be nginx-* or {repo1, repo2}.

    • *: matches any field that does not contain the path separator /.
    • **: matches any field that contains the path separator /.
    • ?: matches any single character except /.
    • {option 1, option 2, ...}: matches any of the options.

    Tag: Image tag. You can use a regular expression to specify tags. The matching rules are the same with those for images.

    NOTE:

    This parameter is available only when the replication direction is Push to target registry.

    library2

    nginx-*

    **

    Source Resource Filter (for pull from target registry)

    Namespace: You can use a regular expression to specify namespaces.

    Image: You can use a regular expression to specify images.

    The regular expression can be nginx-* or {repo1, repo2}.

    • *: matches any field that does not contain the path separator /.
    • **: matches any field that contains the path separator /.
    • ?: matches any single character except /.
    • {option 1, option 2, ...}: matches any of the options.

    Tag: Image tag. You can use a regular expression to specify tags. The matching rules are the same with those for images.

    NOTE:

    This parameter is available only when the replication direction is Pull from target registry.

    library2

    nginx-*

    **

    Trigger Mode

    • Manual: You need to manually trigger image replication.
    • Event + manual: Image replication is triggered when a new image is pushed or pulled and the image meets the regular expression.
    • Scheduled + manual: Scheduled means image replication is triggered periodically.

    Scheduled + manual

    Scheduled

    This parameter is available only when Trigger Mode is set to Scheduled + manual.

    -

    Overwrite

    Whether to overwrite images at the destination with the same name.

    -

    Description

    Enter a description for the policy.

    -

    Figure 1 Creating a replication policy

  5. Click OK.

Replication Policy Examples

  • Push to target registry

    Push all images starting with nginx-in from the library namespace of the local repository to the lib1 namespace of the target repository test-edit-fail. The replication needs to be triggered manually and images with the same name will be overwritten.

  • Pull from target registry

    Pull all images starting with nginx-in from the lib1 namespace of the target repository test-edit-fail to the library1 namespace of the local repository. The replication needs to be triggered manually and images with the same name will be overwritten.

Managing Replication Policies

You can manage your replication policies as follows.

Figure 2 Replication policies
Figure 3 Task details
  • Enable or disable a replication policy. indicates a policy is enabled and indicates the policy is disabled. A new policy is enabled by default.
  • Manually execute a replication policy.
  • Modify a replication policy.
  • Delete a replication policy.
  • View a replication task. When a replication policy is triggered, the images that meet the policy will be replicated. The following table describes details about a replication task.
    Table 2 Replication task parameters

    Parameter

    Description

    Task ID

    Unique ID of a replication task for a repository.

    Status

    Task status.

    Trigger Mode

    The value is Manual or Automatic.

    If you click Execute, the trigger mode is Manual. If the replication is executed periodically based on a schedule, the trigger mode is Automatic.

    Success Rate

    The percentage of images that are successfully replicated to the total number of images that need to be replicated.

    Total

    Total number of images to be replicated in the current task.

    Duration

    Time required to complete a task.

    Created

    Time when a replication task was triggered.

    Operation

    View Details: You can check the replicated images in the right pane after clicking this button.