运维脚本集
定时备份脚本
查看进程OOM分数
程序自动拉起
API调用-Shell
Python调用
Golang调用
K8S镜像下载
本文档使用MrDoc发布
返回首页
-
+
K8S镜像下载
2023年8月28日 17:51
admin
#!/bin/bash HARBOR_IP=192.168.8.60 HARBOR_PORT=81 K8S_DOCKER_LIST=`kubeadm config images list --kubernetes-version=v1.16.4|awk -F '/' '{print $2}'` for k8s_docker_host in ${K8S_DOCKER_LIST[@]} do echo -e "\033[90m检测${k8s_docker_host}镜像...\033[0m" echo $k8s_docker_host | awk -F ':' '{print $1,$2}' | while read NAME VERSION do STATUS=`docker images | grep $NAME | grep $VERSION | wc -l` if [ $STATUS -eq 0 ];then echo -e "\033[91m${k8s_docker_host}镜像不存在,执行拉取镜像...\033[0m" if [ $HARBOR_PORT -eq 80 ];then docker pull ${HARBOR_IP}/k8s/${NAME}:${VERSION} && \ docker tag ${HARBOR_IP}/k8s/${NAME}:${VERSION} k8s.gcr.io/${NAME}:${VERSION} && \ docker rmi ${HARBOR_IP}/k8s/${NAME}:${VERSION} else docker pull ${HARBOR_IP}:${HARBOR_PORT}/k8s/${NAME}:${VERSION} && \ docker tag ${HARBOR_IP}:${HARBOR_PORT}/k8s/${NAME}:${VERSION} k8s.gcr.io/${NAME}:${VERSION} && \ docker rmi ${HARBOR_IP}:${HARBOR_PORT}/k8s/${NAME}:${VERSION} fi if [ $? -ne 0 ];then echo -e "\033[91m拉取${k8s_docker_host}镜像失败,请查看原因...\033[0m" exit fi else echo "${k8s_docker_host}镜像已存在" if [ $HARBOR_PORT -eq 80 ];then docker tag ${HARBOR_IP}/k8s/${NAME}:${VERSION} k8s.gcr.io/${NAME}:${VERSION} 2> /dev/null docker rmi ${HARBOR_IP}/k8s/${NAME}:${VERSION} 2> /dev/null else docker tag ${HARBOR_IP}:${HARBOR_PORT}/k8s/${NAME}:${VERSION} k8s.gcr.io/${NAME}:${VERSION} 2> /dev/null docker rmi ${HARBOR_IP}:${HARBOR_PORT}/k8s/${NAME}:${VERSION} 2> /dev/null fi fi done done
分享到: