拉取和修改kubernetes的docker镜像的python脚本
#encoding:utf8import osS_registry = 'registry.cn-hangzhou.aliyuncs.com/bubblelin/'D_registry = 'k8s.gcr.io/'master_image = ['kube-apiserver:v1.12.0','kube-controller-manager:v1.12.0','kube-scheduler:v
·
#encoding:utf8
import os
S_registry = 'registry.cn-hangzhou.aliyuncs.com/bubblelin/'
D_registry = 'k8s.gcr.io/'
master_image = ['kube-apiserver:v1.12.0','kube-controller-manager:v1.12.0',
'kube-scheduler:v1.12.0','kube-proxy:v1.12.0','flannel:v0.12.0-amd64','pause:3.1',
'etcd:3.2.24','coredns:1.2.2']
def PullImage(registry,images):
print("一共%s个镜像" %(len(images),))
index = 1
for image in images:
print("开始下载第[%d]个镜像 ---> [%s]" %(index,image))
cmd = "docker pull " + registry + image
os.system(cmd)
print("done!")
index +=1
def TagImage(sregistry,dregistry,images):
print("一共%s个镜像" %(len(images),))
index = 1
for image in images:
print("开始tag第[%d]个镜像 ---> [%s] --->[%s]" %(index,sregistry+image,dregistry+image))
cmd = "docker tag " + sregistry+image + " " + dregistry + image
os.system(cmd)
print("done!")
index +=1
if __name__ == '__main__':
# 先执行PullImage,再执行Tag修改源
PullImage(S_registry,master_image)
#TagImage(S_registry,D_registry,master_image)
另外其他的Docker镜像拉取和修改总结可参考:
更多推荐
已为社区贡献3条内容
所有评论(0)