前言

最近突然发现用 Python 写脚本比用 Shell 写脚本快乐的多。由于 csi 在国内拉取真的很麻烦,所以便封装了一个一键拉取脚本。

实现

superPuller.py

import os

mirror = {
    'from': 'registry.aliyuncs.com/google_containers',
    'to': 'k8s.gcr.io/sig-storage',
}

targets = [
    'csi-provisioner:v3.1.0',
    'csi-attacher:v3.4.0',
    'csi-node-driver-registrar:v2.4.0',
    'csi-resizer:v1.4.0',
    'csi-snapshotter:v4.2.0'
]

for target in targets:
    code = os.system('ctr -n k8s.io i pull %s/%s' % (mirror['from'], target))
    if code == 0:
        code = os.system('ctr -n k8s.io i tag %s/%s %s/%s' % (mirror['from'], target, mirror['to'], target))
        if code != 0:
            code = os.system('ctr -n k8s.io i rm %s/%s' % (mirror['from'], target))
            exit(code)
    else:
        exit(code)
最后修改:2022 年 04 月 02 日
如果觉得我的文章对你有用,请随意赞赏