Giter VIP home page Giter VIP logo

image-transfer's Introduction

镜像迁移工具:image-transfer

image-transfer 是一个docker镜像迁移工具,用于对不同镜像仓库的镜像进行批量迁移。

特性

  • 支持多对多镜像仓库迁移
  • 支持腾讯云 TCR 个人版(CCR)一键全量迁移至企业版
  • 支持基于 Docker Registry V2搭建的docker镜像仓库服务 (如 腾讯云TCR个人版(CCR)/TCR企业版、Docker Hub、 Quay、 阿里云镜像服务ACR、 Harbor等)
  • 支持自定义 qps 限速,避免迁移时对仓库造成过大压力
  • 同步不落盘,提升同步速度
  • 利用 pipeline 模型,提高任务执行效率
  • 增量同步, 通过对同步过的镜像 blob 信息落盘,不重复同步已同步的镜像
  • 并发同步,可以通过配置文件调整并发数
  • 自动重试失败的同步任务,可以解决大部分镜像同步中的网络抖动问题
  • 不依赖docker以及其他程序

模式

tcr镜像迁移工具具有两种运行模式:

  • 通用模式:支持多种镜像仓库迁移
  • 腾讯云 CCR 一键全量迁移模式:腾讯云 TCR 个人版(CCR) -> TCR企业版

架构

image

使用

下载和安装

releases页面可下载源码以及二进制文件

手动编译

git clone https://github.com/tkestack/image-transfer.git
cd ./image-transfer

# 编译
make

使用方法

使用帮助

./image-transfer -h

使用示例1:通用模式

设置镜像鉴权配置文件为 registry-secret.yaml,镜像迁移仓库规则文件为 transfer-rule.yaml,默认迁移目标为腾讯云 TCR 个人版:ccr.ccs.tencentyun.com,默认 namespace 为 default,并发数为 5,

./image-transfer --securityFile=./registry-secret.yaml --ruleFile=./transfer-rule.yaml \  
--ns=default --registry=ccr.ccs.tencentyun.com --routines=5 --retry=3

使用示例2:腾讯云 CCR 一键全量迁移模式

打开ccr迁移模式 ccrToTcr=true, 设置镜像仓库鉴权配置文件为 registry-secret.yaml,腾讯云 API 调用密钥配置文件为 tencentcloud-secret.yaml,默认个人版及企业版实例所在地域均为 ap-guangzhou(广州) TCR 企业版实例示例名称为 image-transfer, 并发数为 5,失败重试次数为 3

./image-transfer --ccrToTcr=true --securityFile=./registry-secret.yaml --secretFile=./tencentcloud-secret.yaml \ 
--tcrName=image-transfer --tcrRegion=ap-guangzhou --ccrRegion=ap-guangzhou --routines=5 --retry=3

配置文件参考

腾讯云 API 密钥配置文件 tencentcloud-secret.yaml

如需迁移至腾讯云容器镜像服务内,需配置腾讯云 API 调用密钥,可前往 控制台-访问管理-访问密钥-API密钥管理 获取密钥对。如果在同账号下将 TCR 个人版数据迁移至企业版实例内,可共用同一套密钥。

ccr:
    secretId: xxx
    secretKey: xxx
tcr:
    secretId: xxx
    secretKey: xxx

镜像仓库鉴权配置文件 registry-secret.yaml

配置源目标及迁移目标镜像仓库的访问凭证,即 Docker Login 所使用的用户名,密码。

ccr.ccs.tencentyun.com:
  username: xxx
  password: xxx
image-transfer.tencentcloudcr.com:
  username: xxx
  password: xxx
registry.hub.docker.com:
  username: xxx
  password: xxx
registry.cn-guangzhou.aliyuncs.com:
  username: xxx
  password: xxx
acr.cn-guangzhou.cr.aliyuncs.com:
  username: xxx
  password: xxx

镜像迁移仓库配置文件 transfer-rule.yaml

配置镜像迁移规则,即镜像仓库,镜像版本在源目标及迁移目标内的映射关系。

demo-ns/nginx:latest : image-transfer.tencentcloudcr.com/demo-ns/nginx:latest

image-transfer's People

Contributors

hahchenchen avatar huxiaoliang avatar malc0lm avatar rogerhao avatar wu0407 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

image-transfer's Issues

建议支持指定迁移 tag 版本数

因迁移前镜像仓库内已有大量 tag,迁移至新仓库时不一定需要全量迁移,建议增加一个参数,可指定仅迁移每个仓库内最新的 N 个 tag

建议修改下文档中配置文件示例

文档中给出的配置文件应该是缩进丢失了,运行会出现如下报错

2020-12-30 14:26:30.908 error   configs/config.go:141   decode config file ./rule.yaml error: unmarshal config error: yaml: unmarshal errors:
  line 1: cannot unmarshal !!str `registr...` into map[string]string

建议修改为如下:

镜像鉴权配置文件

grant-test.tencentcloudcr.com:
  username: xxx
  password: xxx
grant-test2.tencentcloudcr.com:
  username: xxx
  password: xxx
registry.cn-hangzhou.aliyuncs.com:
  username: xxx
  password: xxx
ccr.ccs.tencentyun.com:
  username: xxx
  password: xxx
registry.hub.docker.com:
  username: xxx
  password: xxx
test-jingwei.tencentcloudcr.com:
  username: xxx
  password: xxx

镜像迁移仓库配置文件

"sichenzhao/private-test:xx": "grant-test2.tencentcloudcr.com/xxx/xxx"

build fail

go version go1.17.5 linux/amd64

build image-transfer binary
# command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-3508984401/000008.o: unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: 错误的值
collect2: 错误:ld 返回 1

make: *** [binary] 错误 2

建议提供配置文件示例

建议直接在 release 包内提供配置文件示例,下载解压后可直接修改示例配置文件,运行工具,避免因新建配置文件名称,格式问题,导致无法运行工具

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.