批量打包k8s 镜像,然后tag和save到本地harbor,拿走不谢
kubectl get deploy -a -o wide|awk '{print $8}' |grep -v IMAGE>list
#!/bin/bash douhao="," f(){ xiegan="\/" if [[ $1=~$xiegan ]] then res=`echo $1|awk -F '/' '{print $NF}'` echo $res else echo $1 fi } for i in `cat list` do if [[ $i =~ $douhao ]] then array=(${i//,/ }) for y in ${array[@]} do str=`f $y` docker pull $y myharbor="easzlab.io.local:2182/public/$str" docker tag $y $myharbor docker save -o ${str//:-}.tar $myharbor docker rmi $myharbor done else docker pull $i str=`f $i` myharbor="easzlab.io.local:2182/public/$str" docker tag $i $myharbor docker save -o ${str//:-}.tar $myharbor docker rmi $myharbor fi done