Container Registry is a service that is provided by Alibaba Cloud for managing container images. You can use Container Registry to manage the lifecycle of container images in 20 regions around the world. Container Registry is integrated with other Alibaba Cloud services such as Container Service for Kubernetes (ACK) to provide an all-in-one solution for managing cloud-native applications. This topic describes how to use image-syncer to synchronize images from a self-managed Harbor instance to an instance of Container Registry Default Instance Edition.
Prerequisites
You can log on to the Container Registry console to activate Container Registry.
Create a namespace
- Log on to the Container Registry console.
- In the left-side navigation pane, choose .
- On the Namespaces page, click Create Namespace in the upper-right corner.
- In the Create Namespace dialog box, set parameters for the namespace and click Confirm.
After the namespace is created, you can find it on the Namespaces page. You can also manage namespaces on the Namespaces page. For more information, see Manage namespaces.
Grant permissions to a RAM user
Before you perform operations as a Resource Access Management (RAM) user, create a RAM user and grant permissions to the RAM user. Skip this step if you use an Alibaba Cloud account to perform subsequent operations.
Create a credential
Before you pull private images or upload images, you must run the docker login
command to log on to the instance with a credential. Perform the following steps
to create a credential:
- In the left-side navigation pane, choose .
- On the Access Credential page, click Set Password.
- In the Set Password dialog box, set Password and Confirm Password and click OK.
You can call an API operation to obtain a temporary token that you can use to access a Container Registry instance. For more information, see GetAuthorizationToken.
Configure image-syncer
{
"auth": {
"harbor.myk8s.paas.com:32080": {
"username": "admin",
"password": "xxxxxxxxx",
"insecure": true
},
"registry.cn-beijing.aliyuncs.com": {
"username": "acr_pusher@1938562138124787",
"password": "xxxxxxxx"
}
},
"images": {
"harbor.myk8s.paas.com:32080/library/nginx": ""
}
}
harbor.myk8s.paas.com:32080
: the endpoint of the self-managed Harbor instance. You must replace the value with an actual endpoint.username
: the username of the self-managed Harbor instance. The value is admin in this example.password
: the password of the self-managed Harbor instance.insecure
: Set this parameter to true.
registry.cn-beijing.aliyuncs.com
: the endpoint of the destination repository. In this example, the image is deployed in the China (Beijing) region.username
: the username in the credential.password
: the password in the credential.
"harbor.myk8s.paas.com:32080/library/nginx": ""
: access the library/nginx repository through the endpoint harbor.myk8s.paas.com:32080.
Use image-syncer to synchronize images
Synchronization result
Each time you synchronize an image, image-syncer generates a synchronization task, runs the task, and retries if the task fails. Each task synchronizes an image that is represented by a tag. If no tag is specified for a rule in the configuration file, image-syncer lists all the tags in the source repository and generates synchronization tasks for all the images. If image-syncer fails to generate synchronization tasks, image-syncer retries after it runs generated tasks.
- The following figure shows the output of a successful synchronization task.
- The following figure shows the output of a failed synchronization task. Possible reasons
include invalid usernames or passwords.
- The following figure shows the logs of image-syncer.