dxawnw / google_containers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

关于

可以去阿里云镜像仓库市场看看registry.aliyuncs.com/google_containers实际上这个ns是用户创建的。

由于这个ns的所有者同步太慢了,我便写了这个工具来时刻同步

本仓库只同步gcr.io/google_containers ==> registry.aliyuncs.com/k8sxio

目前已经同步完了,可以看travis-ci的运行状态

特性

  • 不依赖 Docker 运行

  • 同步期间不占用本地磁盘空间(直接通过标准库转发镜像)

  • 可控的并发同步(优雅关闭/可调节并发数量)

  • 核心拷贝方法引用的containers/images,部分代码借鉴了mritd

  • 利用boltdb存储每个镜像的crc32校验值,通过比对判断是否需要同步

  • 把boltdb文件放docker镜像里存在dockerhub上,利用travis的api来重启travis-ci的runner来同步

用法

编译的话记得带上tag,关闭CGO

go build -tags=containers_image_openpgp main.go

sync命令是同步的命令,sum是查看boltdb文件的信息

imgsync sync --help
            
    Sync docker images.
    
    Usage:
      imgsync sync [flags]
    
    Flags:
          --command-timeout duration   timeout for the command execution.
          --db string                  the boltdb file (default "bolt.db")
      -h, --help                       help for sync
          --img-timeout duration       sync single image timeout. (default 15m0s)
          --live-interval duration     live output for travis-ci.
      -p, --password string            The password to push.
          --process-limit int          sync process limit. (default 2)
          --push-ns string             the ns push to
          --push-to string             the repo push to (default "docker.io")
          --query-limit int            http query limit. (default 10)
          --retry int                  retry count while err. (default 4)
          --retry-interval duration    retry interval while err. (default 4s)
      -u, --user string                The username to push.
    
    Global Flags:
          --debug   debug mode

示例

在travis-ci的设置那里设置好环境变量来控制运行的一些属性,也可以把镜像同步到自己的内网仓库上

  ${HOME}/sync/imgsync sync 
  --db ${HOME}/sync/bolt.db 
  --push-to registry.aliyuncs.com 
  --password ${PASS} 
  --push-ns=k8sxio 
  --user zhangguanzhang@qq.com 
  --command-timeout ${TMOUT} 
  --process-limit ${PROCESS:=2}
  --img-timeout ${IMG_TMOUT:=10m} 
  --live-interval ${LIVE:=9m20s}
  --debug=${DEBUG:=false} 
  google_containers

About

License:MIT License


Languages

Language:Go 83.9%Language:Shell 13.7%Language:Dockerfile 2.4%