k8s迁移Pod流程
获取deployment images/pull/ 打tag/push新仓库
#!/bin/bash
for x in ` kubectl -n cbf-quhui get deploy -o wide|awk '{print $7}'`
do
A=`echo $x|awk -F':|/' '{print $(NF-1)}'`
docker pull $x
docker tag $x harbor-ioscar.cbf.com/v3-test/$A:cbf-quhui
docker push harbor-ioscar.cbf.com/v3-test/$A:cbf-quhui
done
获取deploymentName 追加--- 新环境创建deployment
#!/bin/bash for i in $(cat /root/mzkk/cbf-quhui/quhui-deploy-name.txt) do kubectl -n cbf-quhui get deploy $i -o yaml >> /root/mzkk/cbf-quhui/download-deploy.yaml sed -i '$a\---' /root/mzkk/cbf-quhui/download-deploy.yaml done
更新当前cbf-quhui 环境全部镜像
#!/bin/bash
# harbor-ioscar.cbf.com/v3-test/workorder-serviceworker:cbf-quhui
ns="cbf-quhui"
for i in $(cat /root/mzk/cbf-quhui/quhui-deploy-name.txt)
do
imageName="harbor-ioscar.cbf.com/v3-test/${i}:${ns}"
echo "$imageName"
kubectl -n ${ns} set image deploy/${i} ${i}=${imageName}
done
获取svc名字
kubectl -n cbf-quhui get svc | awk '{print $1}' >> svc-name.txt
获取svc-deployment
#!/bin/bash for i in $(cat /root/mzkk/cbf-quhui/svc-name.txt) do kubectl -n cbf-quhui get svc $i -o yaml >> /root/mzkk/cbf-quhui/download-svc.yaml sed -i '/clusterIP: 10.255/d' /root/mzkk/cbf-quhui/download-svc.yaml sed -i '$a\---' /root/mzkk/cbf-quhui/download-svc.yaml done
sed 删除掉cluster ip
sed -i '/clusterIP: 10.255/d'

浙公网安备 33010602011771号