{"id":18697551,"url":"https://github.com/zhangguanzhang/google_containers","last_synced_at":"2025-08-27T15:12:19.185Z","repository":{"id":57637337,"uuid":"148296152","full_name":"zhangguanzhang/google_containers","owner":"zhangguanzhang","description":null,"archived":false,"fork":false,"pushed_at":"2022-08-14T13:24:35.000Z","size":101,"stargazers_count":164,"open_issues_count":1,"forks_count":38,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-09T12:43:00.311Z","etag":null,"topics":["images-sync"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhangguanzhang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-11T09:50:45.000Z","updated_at":"2024-12-08T08:41:12.000Z","dependencies_parsed_at":"2022-08-30T16:02:03.557Z","dependency_job_id":null,"html_url":"https://github.com/zhangguanzhang/google_containers","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangguanzhang%2Fgoogle_containers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangguanzhang%2Fgoogle_containers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangguanzhang%2Fgoogle_containers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangguanzhang%2Fgoogle_containers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhangguanzhang","download_url":"https://codeload.github.com/zhangguanzhang/google_containers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230501172,"owners_count":18236061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["images-sync"],"created_at":"2024-11-07T11:24:44.393Z","updated_at":"2024-12-19T21:09:54.641Z","avatar_url":"https://github.com/zhangguanzhang.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 关于\n\n可以去[阿里云镜像仓库市场](https://cr.console.aliyun.com/images/cn-hangzhou/google_containers/kube-apiserver/detail)看看`registry.aliyuncs.com/google_containers`实际上这个ns是用户创建的。\n\n由于这个ns的所有者同步太慢了，我便写了这个工具来时刻同步\n\n本仓库只同步`k8s.gcr.io` ==\u003e `registry.aliyuncs.com/k8sxio`，目前`gcr.io/google_containers`已经不和`k8s.gcr.io`一致了，所以目前只同步`k8s.gcr.io`\n\n目前已经同步完了，可以看[github action的运行状态](https://github.com/zhangguanzhang/google_containers/actions)\n\n\n查看镜像列表的话去[阿里云镜像仓库市场](https://cr.console.aliyun.com/cn-hangzhou/instances/images) \n\n登录后在搜索框那输入`k8sxio/`搜索即可，也可以看单独的镜像例如`k8sxio/kube-apiserver`\n\n## 特性\n\n- **不依赖 Docker 运行**\n- **同步期间不占用本地磁盘空间(直接通过标准库转发镜像)**\n- **可控的并发同步(优雅关闭/可调节并发数量)**\n\n\n- 核心拷贝方法引用的[containers/image](https://github.com/containers/image)，部分代码借鉴了[mritd](https://github.com/mritd/imgsync)\n\n- 利用 boltdb 存储每个镜像 manifest 信息的 crc32 校验值，通过比对判断是否需要同步，而不是每次请求目标仓库\n- 把 boltdb 文件放 docker镜像里存在 dockerhub 上，多次运行 action 来同步\n\n\n## 用法\n\n编译的话记得带上tag，关闭CGO\n```shell\ngo build -tags=containers_image_openpgp main.go\n```\n\nsync命令是同步的命令，sum是查看boltdb文件的信息\n```cassandraql\nimgsync sync --help\n            \n    Sync docker images.\n    \n    Usage:\n      imgsync sync [flags]\n    \n    Flags:\n          --addition-ns stringArray    addition ns to sync (default [])\n          --command-timeout duration   timeout for the command execution.\n          --db string                  the boltdb file (default \"bolt.db\")\n      -h, --help                       help for sync\n          --img-timeout duration       sync single image timeout. (default 15m0s)\n          --live-interval duration     live output for travis-ci.\n          --login-retry uint8          login retry when timeout. (default 2)\n      -p, --password string            The password to push.\n          --process-limit int          sync process limit. (default 2)\n          --push-ns string             the ns push to\n          --push-to string             the repo push to (default \"docker.io\")\n          --query-limit int            http query limit. (default 10)\n          --retry int                  retry count while err. (default 4)\n          --retry-interval duration    retry interval while err. (default 4s)\n      -u, --user string                The username to push.\n    \n    Global Flags:\n          --debug   debug mode\n\n```\n\n### 示例\n\n那里设置好环境变量来控制运行的一些属性，也可以把镜像同步到自己的内网仓库上\n```cassandraql\n  ${HOME}/sync/imgsync sync \n  --db ${HOME}/sync/bolt.db \n  --push-to registry.aliyuncs.com \n  --password ${PASS} \n  --push-ns=k8sxio \n  --user zhangguanzhang@qq.com \n  --command-timeout ${TMOUT} \n  --process-limit ${PROCESS:=2}\n  --img-timeout ${IMG_TMOUT:=10m} \n  --live-interval ${LIVE:=9m20s}\n  --login-retry ${LOGIN_RETRY:=2}\n  --debug=${DEBUG:=false} \n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangguanzhang%2Fgoogle_containers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhangguanzhang%2Fgoogle_containers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangguanzhang%2Fgoogle_containers/lists"}