add run
This commit is contained in:
parent
de04d25033
commit
2a6d992e67
17
README.md
17
README.md
|
@ -48,6 +48,23 @@ incloud mirror.txt
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
|
|
||||||
|
## 安装运行
|
||||||
|
|
||||||
|
安装 skopeo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
运行同步程序
|
||||||
|
|
||||||
|
```
|
||||||
|
export REGISTRY_PASSWORD=password #镜像仓库密码
|
||||||
|
python scripts/sync-to-jp.py
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## 最佳实践
|
## 最佳实践
|
||||||
* 通过 加速 安装 kubeadm
|
* 通过 加速 安装 kubeadm
|
||||||
* 通过 加速 运行 artifacthub 上的镜像
|
* 通过 加速 运行 artifacthub 上的镜像
|
|
@ -0,0 +1,39 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
REPO_REPLACE_RULE = {
|
||||||
|
"gcr.io":"gcr-jp.m.daocloud.io",
|
||||||
|
"k8s.gcr.io":"k8s-gcr-jp.m.daocloud.io",
|
||||||
|
"docker.io":"docker-jp.m.daocloud.io",
|
||||||
|
"quay.io":"quay-jp.m.daocloud.io",
|
||||||
|
"ghcr.io":"ghcr-jp.m.daocloud.io",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
REGISTRY_PASSWORD = os.environ["REGISTRY_PASSWORD"]
|
||||||
|
|
||||||
|
|
||||||
|
SKEPO_CMD = "docker run -it quay.io/containers/skopeo:latest"
|
||||||
|
# SKEPO_CMD = "skepo" # RUN without docker
|
||||||
|
|
||||||
|
def skepo_sync_cmd(src_img):
|
||||||
|
src_img = src_img.strip()
|
||||||
|
dest_img = "/".join(src_img.split("/")[:-1])
|
||||||
|
cmd = SKEPO_CMD + " sync --src docker --dest %s --dest-tls-verify=false --dest-creds root:%s -f oci %s" %(src_img,REGISTRY_PASSWORD,dest_img)
|
||||||
|
# print(src_img)
|
||||||
|
# print(dest_img)
|
||||||
|
# print(cmd)
|
||||||
|
return cmd
|
||||||
|
|
||||||
|
def main():
|
||||||
|
lines = []
|
||||||
|
with open("mirror.txt") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
sync_cmds = []
|
||||||
|
for l in lines:
|
||||||
|
sync_cmds.append(skepo_sync_cmd(l))
|
||||||
|
for c in sync_cmds:
|
||||||
|
os.system(c)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# execute only if run as a script
|
||||||
|
main()
|
Loading…
Reference in New Issue