winloong 3 years ago
parent
commit
c272db6c26
  1. 7
      .gitignore
  2. BIN
      syncimages/__pycache__/app.cpython-38.pyc
  3. BIN
      syncimages/__pycache__/harbor.cpython-38.pyc
  4. BIN
      syncimages/__pycache__/k8s.cpython-38.pyc
  5. 44
      syncimages/app.py
  6. 19
      syncimages/config
  7. 102
      syncimages/dispatch.sh
  8. 35
      syncimages/harbor.py
  9. 0
      syncimages/hosts.txt
  10. 86
      syncimages/images.txt
  11. 0
      syncimages/images/repository.anxinyun.cn_anxin_iota-proxy38.21-11-29.tar
  12. 0
      syncimages/images/repository.anxinyun.cn_anxin_iota-proxydragon.33.tar
  13. 0
      syncimages/images/repository.anxinyun.cn_anxincloud_et.iotaraw20-11-10.1.tar
  14. 0
      syncimages/images/repository.anxinyun.cn_anxincloud_et.iotaraw4.21-04-09.tar
  15. 0
      syncimages/images/repository.anxinyun.cn_anxinyun_actionview-dashboard11.21-12-09.tar
  16. 0
      syncimages/images/repository.anxinyun.cn_anxinyun_config_center35.21-07-16.tar
  17. 0
      syncimages/images/repository.anxinyun.cn_anxinyun_console-web143.22-03-23.tar
  18. 0
      syncimages/images/repository.anxinyun.cn_anxinyun_receiver12.21-04-15.tar
  19. 0
      syncimages/images/repository.anxinyun.cn_firecontrol_anfang-2b-datapush44.22-04-21.tar
  20. 0
      syncimages/images/repository.anxinyun.cn_firecontrol_anfangapi-2bctrl76.22-04-20.tar
  21. 0
      syncimages/images/repository.anxinyun.cn_firecontrol_anfangapi39.22-01-21.tar
  22. 0
      syncimages/images/repository.anxinyun.cn_firecontrol_anfangdatapush22.22-01-21.tar
  23. 0
      syncimages/images/repository.anxinyun.cn_firecontrol_anfangweb-2bctrl47.22-04-20.tar
  24. 0
      syncimages/images/repository.anxinyun.cn_firecontrol_anfangweb-2b190.22-04-20.tar
  25. 0
      syncimages/images/repository.anxinyun.cn_firecontrol_anfangweb31.22-01-21.tar
  26. 0
      syncimages/images/repository.anxinyun.cn_shushijia_web106.22-02-28.tar
  27. 0
      syncimages/images/repository.anxinyun.cn_smart_camundademo22-04-12.24.tar
  28. 0
      syncimages/images/repository.anxinyun.cn_smartcity_smartsafety-console31.21-12-20.tar
  29. 0
      syncimages/images/repository.anxinyun.cn_smartcity_worksafety-webapi21-07-01.15.tar
  30. 36
      syncimages/k8s.py
  31. 49
      syncimages/pull.sh

7
.gitignore

@ -0,0 +1,7 @@
/node_modules/
.svn/
.git/
.vscode/
.idea/
.history/
venv

BIN
syncimages/__pycache__/app.cpython-38.pyc

Binary file not shown.

BIN
syncimages/__pycache__/harbor.cpython-38.pyc

Binary file not shown.

BIN
syncimages/__pycache__/k8s.cpython-38.pyc

Binary file not shown.

44
syncimages/app.py

@ -0,0 +1,44 @@
import k8s
import harbor
import os
import argparse
argparser = argparse.ArgumentParser()
argparser.description = '输入一个参数,--is_first '
argparser.add_argument('-f', '--is_first', dest='is_first', default=False, help='是否是第一次执行')
ns_list = ['anxinyun']
def first_get_all():
for ns in ns_list:
image_list = k8s.list_deployment(ns)
out_file(image_list)
def out_file(image_list):
image_url_list = list(
map(lambda i: "repository.anxinyun.cn/{}/{}:{}".format(i['project'], i['name'], i['tag']), image_list))
if os.path.exists('images.txt'):
os.remove("images.txt")
with open("images.txt", "a") as file:
file.writelines(s + '\n' for s in image_url_list)
def get_latest_images():
pre_image_list = []
for ns in ns_list:
image_list = k8s.list_deployment(ns)
for image in image_list:
tag = harbor.get_image_latest_tag(image['project'], image['name'])
if tag != image['tag']:
pre_image_list.append(image)
out_file(pre_image_list)
if __name__ == '__main__':
args = argparser.parse_args()
if args.is_first:
first_get_all()
else:
get_latest_images()

19
syncimages/config

@ -0,0 +1,19 @@
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeE1USXdOV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4U3NOdU5pb2pzSkpvd0tVcVo2dXVwRkFYMmhLQgpla3UxbXpQa2ErazhnUmNEdlVqVExPU0g3RVhiYU4wR0IzUHU2dVdnREJvbkF5TU12aHJHazFFNlBOS1lKZGhzCk5YcDFINFVvOXoxbytwRE1pbldGY2lueXUyZUFTWFYvZ0dmSytUMHBkU29wSW9tRlBxS1ZZcXExVENnMjJuWmoKNkprPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
server: https://10.8.30.157:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJWkE5K2FJN0ZTV293RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TVRFeU1EVXhORFU1TVRsYUZ3MHlNakV5TURVeE5EVTVNakphTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXhoaFYrOFd3ZDB3bmpXKzMKV1MrQ050RmlYMENXbFMrM0VKNHYrWitMbXZjckVHQmtobUwrWXlaeUJ6ZFZ3dmNKK2FHMHgwdE9wd203bzZSVApqZ1VjVUdLd0toZXQzZW5SVlM3dkJpaXdnQVF0RVRrMit0MWR5dFMyVDYrbUFkZUhnWWhBWkw2cEFpQi92anJkCmF3dk05T3o1d2o2d2dCaXFKV25SUFQ0dlQvR0lRaTFTUDh4c1QyRmVZVVRnc2hleEltNnJkVHAxeVlFZ0hhTnAKU0JhelRJaERxajFsS0twNDk5bThPQ1BpL3BCbVpx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*-images.txt 文件 \033[0m"
exit
fi
if [ ! -f "${1}" ]; then
echo -e "\033[31m 文件 ${1} 不存在 \033[0m"
exit
fi
if [ x${2} = x ]; then
echo -e "\033[31m 请在第二个命令行参数指定 target-hosts.txt 文件 \033[0m"
exit
fi
if [ ! -f "${2}" ]; then
echo -e "\033[31m 文件 ${2} 不存在 \033[0m"
exit
fi
read line < ${2}
prvKey=$(echo ${line})
if [ ! -f "${prvKey}" ]; then
echo -e "\033[31m 文件 '${prvKey}' 不存在,请在文件 ${2} 的第一行指定 ssh privateKey 的路径 \033[0m"
exit
fi
while read line
do
let count++
if [ ${count} -gt 1 ]; then
line=$(echo $line)
if [ x${line} = x ]; then
continue
fi
user=$(echo ${line%@*})
ipport=$(echo ${line#*@})
ip=$(echo ${ipport%:*})
port=$(echo ${ipport#*:})
if [ x${user} = x${line} -o x${ip} = x${ipport} -o x${port} = x${ipport} ]; then
echo -e "\033[31m 文件 ${2} 的第 ${count} 行应该符合 user@192.168.2.10:22 的格式,当前该行内容为: \033[0m"
echo ${line}
exit
fi
hostIndex=`expr ${count} - 1`
echo -e "\033[36m>>>>> 开始分发镜像到第 ${hostIndex} 个目标主机 ${ip} >>>>>\033[0m"
scp -P ${port} -i ${prvKey} ${1} ${user}@${ip}:~/
ssh -p ${port} -i ${prvKey} ${user}@${ip} "rm -rf ${1%???????} || true
echo -e \"\033[36mstep ${hostIndex}.1 解压缩\033[0m\"
tar zxvf ${1}
echo -e \"\033[36mstep ${hostIndex}.2 加载镜像\033[0m\"
while read line
do
let c++
line=\$(echo \${line})
if [ x\${line} = x ]; then
echo -e \"Step ${hostIndex}.2.\${c} \033[33m第 \${c} 行为空\033[0m\"
continue
fi
echo -e \"Step ${hostIndex}.2.\${c} docker load < ${1%???????}/\${line//\//_}.tar \\t \\c\"
line=\$(echo \$line)
docker load < ${1%???????}/\${line//\//_}.tar
done < ${1%???????}/images.txt
echo -e \"\033[36m加载到目标主机 ${ip} 的镜像如下\033[0m\"
echo -e \"IMAGE ID\t CREATED\t\tSIZE\t\t REPOSITORY:TAG\"
while read line
do
line=\$(echo \${line})
if [ x\${line} = x ]; then
continue
fi
tag=\$(echo \${line%:*})
version=\$(echo \${line%:*})
docker images \${line} --format \"table {{.ID}}\t{{.CreatedSince}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}\" | grep \${tag} | grep \${version}
done < ${1%???????}/images.txt
echo
echo -e \"\033[36m清理目标主机 ${ip} 上的临时文件\033[0m\"
rm -rf ${1%???????} || true
rm -rf ${1} || true
echo
" < /dev/null
echo -e "\033[32m<<<<< 已结束将镜像分发到第 ${hostIndex} 个目标主机 ${ip} <<<<<\033[0m"
echo ""
fi
done < ${2}
echo -e "\033[32m----- 已结束将镜像分发到 ${2} 文件中定义的所有主机 -----\033[0m"
echo ""

35
syncimages/harbor.py

@ -0,0 +1,35 @@
import requests
from urllib import parse
session = requests.Session()
HEADERS = {'Content-Type': 'application/x-www-form-urlencoded'}
def get_session():
payload = {"principal": 'admin', "password": 'Harbor12345'}
data = parse.urlencode(payload)
r = session.post("https://repository.anxinyun.cn/login", headers=HEADERS, data=data)
print(r.status_code)
def get_all_project():
url = "https://repository.anxinyun.cn/api/projects?page=1&page_size=100"
rs = session.get(url)
if rs.status_code == 200:
projects = dict()
for p in rs.json():
projects[p['name']] = p['project_id']
return projects
def get_image_latest_tag(project, image):
url = "https://repository.anxinyun.cn/api/repositories/{}/{}/tags?detail=1".format(project, image)
r = session.get(url)
if r.status_code == 200:
tags = list(map(lambda t: {'created': t['created'], 'tag': t['name']}, r.json()))
tags.sort(key=lambda x: x['created'], reverse=True)
return tags[0]['tag'] if len(tags) == 1 else tags[0]['tag'] if tags[0]['tag'] != 'latest' else tags[1]['tag']
# if len(tags) >= 2:
# return tags[0]['tag'] if tags[0]['tag'] != 'latest' else tags[1]['tag']
# else:
# return tags[0]['tag']

0
syncimages/hosts.txt

86
syncimages/images.txt

@ -0,0 +1,86 @@
repository.anxinyun.cn/anxinyun/actionview-dashboard:11.21-12-09
repository.anxinyun.cn/firecontrol/anfang-2b-datapush:44.22-04-21
repository.anxinyun.cn/firecontrol/anfangdatapush:22.22-01-21
repository.anxinyun.cn/firecontrol/anfangweb-2b:190.22-04-20
repository.anxinyun.cn/firecontrol/anfangapi-2bctrl:76.22-04-20
repository.anxinyun.cn/firecontrol/anfangweb-2bctrl:47.22-04-20
repository.anxinyun.cn/firecontrol/anfangweb:31.22-01-21
repository.anxinyun.cn/firecontrol/anfangapi:39.22-01-21
repository.anxinyun.cn/smartcity/smartsafety-console:31.21-12-20
repository.anxinyun.cn/smartcity/worksafety-webapi:21-07-01.15
repository.anxinyun.cn/smart/camundademo:22-04-12.24
repository.anxinyun.cn/anxinyun/config_center:35.21-07-16
repository.anxinyun.cn/anxinyun/console-web:143.22-03-23
repository.anxinyun.cn/anxincloud/et.iotaraw:20-11-10.1
repository.anxinyun.cn/anxincloud/et.iotaraw:4.21-04-09
repository.anxinyun.cn/anxin/iota-proxy:38.21-11-29
repository.anxinyun.cn/anxin/iota-proxy:dragon.33
repository.anxinyun.cn/anxin/iota-proxy:dragon.33
repository.anxinyun.cn/anxinyun/receiver:12.21-04-15
repository.anxinyun.cn/shushijia/web:106.22-02-28
repository.anxinyun.cn/shushijia/webapi:333.22-04-11
repository.anxinyun.cn/anxinyun/weather:dragon.3
repository.anxinyun.cn/anxincloud/weather-history:11.21-04-02
repository.anxinyun.cn/smart/camundademo:22-04-18.25
repository.anxinyun.cn/smart/camundademo:22-04-08.23
repository.anxinyun.cn/shushijia/datapush:62.21-03-16
repository.anxinyun.cn/shushijia/report:69.22-04-13
repository.anxinyun.cn/shushijia/report-web:112.22-04-13
repository.anxinyun.cn/anxinyun/weatherhttp:20-10-22.1
repository.anxinyun.cn/projectmanagement/emis.webapi:214.22-04-20
repository.anxinyun.cn/projectmanagement/emis.webapi:186.22-04-11
repository.anxinyun.cn/projectmanagement/emis.web:300.22-04-21
repository.anxinyun.cn/projectmanagement/emis.web:271.22-04-12
repository.anxinyun.cn/fs-env/env.api:113.22-04-06
repository.anxinyun.cn/fs-env/api.public:dragon.9
repository.anxinyun.cn/smartcity/zhujianju-console:114.21-04-29
repository.anxinyun.cn/anxinyun/zhujianju:66.21-05-08
repository.anxinyun.cn/devops/flink:1.9.3-scala_2.11
repository.anxinyun.cn/devops/flink:1.9.3-scala_2.11
repository.anxinyun.cn/smartsite/shunkongsite-api:8.22-04-01
repository.anxinyun.cn/smartsite/shunkongsite-web:13.22-04-20
repository.anxinyun.cn/anxinyun/console-web:11.22-04-15
repository.anxinyun.cn/anxinyun/api:13.22-04-15
repository.anxinyun.cn/smartcity/filemanagement.api:7.22-04-08
repository.anxinyun.cn/smartcity/filemanagement.web:17.22-04-20
repository.anxinyun.cn/smartsite/jingdezhen-api:70.22-04-18
repository.anxinyun.cn/smartsite/jingdezhen_web:114.22-04-18
repository.anxinyun.cn/smartsite/process:54.22-02-24
repository.anxinyun.cn/anxinyun/gonghui:237.22-04-20
repository.anxinyun.cn/projectmanagement/oa.web:53.22-04-13
repository.anxinyun.cn/projectmanagement/oa.web:45.22-03-25
repository.anxinyun.cn/projectmanagement/pep.web:67.22-04-20
repository.anxinyun.cn/projectmanagement/pep.web:53.22-03-25
repository.anxinyun.cn/projectmanagement/pg.web:393.22-04-13
repository.anxinyun.cn/projectmanagement/pg.web:389.22-04-01
repository.anxinyun.cn/projectmanagement/pg.webapi:320.22-04-21
repository.anxinyun.cn/projectmanagement/pg.webapi:311.22-04-09
repository.anxinyun.cn/smartcity/smart-emergency-api:37.22-04-19
repository.anxinyun.cn/device/emergency_reportservice:43.22-03-30
repository.anxinyun.cn/smartcity/smartemergency-web:20.22-03-30
repository.anxinyun.cn/smartsite/web:408.22-04-20
repository.anxinyun.cn/smartsite/et-smartsite:19.21-12-29
repository.anxinyun.cn/smartsite/process:54.22-02-24
repository.anxinyun.cn/smartsite/smartsite-api:225.22-04-07
repository.anxinyun.cn/smartsite/ghm-webconsole:peter.32
repository.anxinyun.cn/smartsite/gmh-webapi:peter.28
repository.anxinyun.cn/smartcity/smarttourism-console:20.22-04-20
repository.anxinyun.cn/smartcity/smarttourism-process:21-09-27.33
repository.anxinyun.cn/smartcity/smarttourism-webapi:21-09-27.99
repository.anxinyun.cn/smartwater/smartwater.web:55.21-12-03
repository.anxinyun.cn/smartwater/smartwater.api:21.21-11-16
repository.anxinyun.cn/smartsite/tianjinapi:9.22-04-12
repository.anxinyun.cn/smartsite/tianjinweb:30.22-04-18
repository.anxinyun.cn/toilet/toilet.web:70.22-04-20
repository.anxinyun.cn/toilet/toilet.api:30.21-10-11
repository.anxinyun.cn/anxin/tool-api:dragon.4
repository.anxinyun.cn/smartchangnan/new_web:11.22-04-14
repository.anxinyun.cn/anxinyun/api:11.22-04-15
repository.anxinyun.cn/smartcity/xiaolanfangyivideo-console:6.22-04-03
repository.anxinyun.cn/smartsite/smartsitezq.api:3.22-03-17
repository.anxinyun.cn/smartcity/xiaolan-web:13.21-12-27
repository.anxinyun.cn/smartcity/xiaolan-webapi-new:21-12-18.25
repository.anxinyun.cn/firecontrol/anfangapi:39.22-01-21
repository.anxinyun.cn/firecontrol/anfangweb:31.22-01-21
repository.anxinyun.cn/smartsite/smartsitezq-api:2.22-03-22
repository.anxinyun.cn/smartsite/zqweb:2.22-03-22

0
syncimages/images/repository.anxinyun.cn_anxin_iota-proxy38.21-11-29.tar

0
syncimages/images/repository.anxinyun.cn_anxin_iota-proxydragon.33.tar

0
syncimages/images/repository.anxinyun.cn_anxincloud_et.iotaraw20-11-10.1.tar

0
syncimages/images/repository.anxinyun.cn_anxincloud_et.iotaraw4.21-04-09.tar

0
syncimages/images/repository.anxinyun.cn_anxinyun_actionview-dashboard11.21-12-09.tar

0
syncimages/images/repository.anxinyun.cn_anxinyun_config_center35.21-07-16.tar

0
syncimages/images/repository.anxinyun.cn_anxinyun_console-web143.22-03-23.tar

0
syncimages/images/repository.anxinyun.cn_anxinyun_receiver12.21-04-15.tar

0
syncimages/images/repository.anxinyun.cn_firecontrol_anfang-2b-datapush44.22-04-21.tar

0
syncimages/images/repository.anxinyun.cn_firecontrol_anfangapi-2bctrl76.22-04-20.tar

0
syncimages/images/repository.anxinyun.cn_firecontrol_anfangapi39.22-01-21.tar

0
syncimages/images/repository.anxinyun.cn_firecontrol_anfangdatapush22.22-01-21.tar

0
syncimages/images/repository.anxinyun.cn_firecontrol_anfangweb-2bctrl47.22-04-20.tar

0
syncimages/images/repository.anxinyun.cn_firecontrol_anfangweb-2b190.22-04-20.tar

0
syncimages/images/repository.anxinyun.cn_firecontrol_anfangweb31.22-01-21.tar

0
syncimages/images/repository.anxinyun.cn_shushijia_web106.22-02-28.tar

0
syncimages/images/repository.anxinyun.cn_smart_camundademo22-04-12.24.tar

0
syncimages/images/repository.anxinyun.cn_smartcity_smartsafety-console31.21-12-20.tar

0
syncimages/images/repository.anxinyun.cn_smartcity_worksafety-webapi21-07-01.15.tar

36
syncimages/k8s.py

@ -0,0 +1,36 @@
from kubernetes import client, config
config.load_kube_config("D:/workspace/pythonprojects/syncimages/config")
apps_v1 = client.AppsV1Api()
core_v1 = client.CoreV1Api()
def list_deployment(ns):
image_list = []
deploy_list = apps_v1.list_namespaced_deployment(namespace=ns).items
for item in deploy_list:
if item.spec.template.spec.containers[0].image.startswith('repository.anxinyun.cn'):
project_image = get_project(item.spec.template.spec.containers[0].image)
image_tag = get_image_tag(project_image[2])
image_list.append({'project': project_image[1], 'name': image_tag[0], 'tag': image_tag[1]})
return image_list
def get_project(image_url):
return image_url.split("/")
def get_image_tag(image):
return image.split(":")
def list_node():
nodes = core_v1.list_node()
for node in nodes.items:
print(node.metadata.name)
if __name__ == '__main__':
list_deployment()
# print(get_project('repository.anxinyun.cn/anxinyun/actionview-dashboard:11.21-12-09'))

49
syncimages/pull.sh

@ -0,0 +1,49 @@
#!/bin/bash
folder=${1%.*}
echo ${folder}
if [ x"${folder}" = x ]; then
echo -e "\033[31m 请指定 *-images.txt 文件 \033[0m"
exit
fi
echo ""
echo "创建临时文件夹 ${folder}"
echo ""
rm -rf ${folder} || true
mkdir ${folder}
while read line
do
let count++
line=$(echo $line)
if [ x${line} = x ]; then
echo -e "\033[33m第 ${count} 行为空\033[0m"
echo
continue
fi
echo ">>>>> 下载第 ${count} 个镜像 ${line} >>>>>"
docker pull $line;
echo -e "\033[32m<<<<< 保存第 ${count} 个镜像到 ${folder}/${line//\//_}.tar \033[0m";
docker save $line > ${folder}/${line//\//_}.tar;
echo ""
done < ${1}
echo "----- 创建压缩文件 ${folder}.tar.gz -----"
cp ${1} ${folder}/images.txt
tar -zcvf ${folder}.tar.gz ${folder}/*.tar ${folder}/images.txt
echo -e "\033[32m----- 已压缩到文件 ${folder}.tar.gz ----- \033[0m"
echo -e "文件大小为 \c"
ls -hl ${folder}.tar.gz | awk '{print $5}'
echo ""
echo "清除临时文件夹 ${folder}"
rm -rf ${folder}
echo ""
echo "请执行以下指令,将镜像分发到 ./target-hosts.txt 文件中定义的目标主机上。"
echo -e "\033[36m./dispatch.sh ${folder}.tar.gz target-hosts.txt \033[0m"
echo ""