Commit d63280a3 by wangtingwei

去掉sed recover逻辑,优化为拷贝模板到/tmp目录。

1 parent 3a8bf839
Showing with 21 additions and 22 deletions
#!/bin/bash #!/bin/bash
#wangtingwei #wangtingwei
IMAGE_NAME=`cat image_list.txt` #获取最新launcher镜像完整名字 IMAGE_NAME=`cat image_list.txt` #获取最新launcher镜像完整名字
PRI_IMAGE_NAME=`echo $IMAGE_NAME |awk -F '/' '{print $3}'` #截断只保留镜像名字和tag部分 PRI_IMAGE_NAME=`echo $IMAGE_NAME |awk -F '/' '{print $NF}'` #截断只保留镜像名字和tag部分
date=date +%F-%H-%M
workspace=/workspace/seetaas
#################################################################### ####################################################################
kubectl get ns |grep volcano-system kubectl get ns |grep volcano-system
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
...@@ -11,43 +13,40 @@ else ...@@ -11,43 +13,40 @@ else
fi fi
#################################################################### ####################################################################
sed_image_name () { sed_image_name () {
echo "###############sed修改部署在公有环境的镜像名字#####################" echo "拷贝yaml到临时目录,公有云环境下sed修改镜像"
sleep 2 sleep 2
sed -i s@IMAGE_NAME@$IMAGE_NAME@g k8s_yaml/kpl-launcher/deployment.yaml cp -a $workspace/src/kpl-launcher/k8s_yaml/kpl-launcher/deployment.yaml /tmp/deployment-$date.yaml
} sed -i s@IMAGE_NAME@$IMAGE_NAME@g /tmp/deployment-$date.yaml
recover_image_name () {
echo "################恢复launcher镜像模板###########################"
sleep 2
sed -i s@$IMAGE_NAME@IMAGE_NAME@g k8s_yaml/kpl-launcher/deployment.yaml
}
#################################################################### ####################################################################
private_sed_image_name() { private_sed_image_name() {
sed -i s@hub.kce.ksyun.com/aivc/volcanosh/vc-scheduler:latest@harbor_host/k8s/vc-scheduler:latest@g /workspace/seetaas/src/kpl-launcher/k8s_yaml/volcano/volcano-development.yaml cp -a $workspace/src/kpl-launcher/k8s_yaml/volcano/volcano-development.yaml /tmp/volcano-development-$date.yaml #拷贝到临时目录,sed不修改模板文件。这样就避免了sed修改出错的问题,不需要在recover sed
sed -i s@hub.kce.ksyun.com/aivc/volcanosh/vc-webhook-manager:latest@harbor_host/k8s/vc-webhook-manager:latest@g /workspace/seetaas/src/kpl-launcher/k8s_yaml/volcano/volcano-development.yaml cp -a $workspace/src/kpl-launcher/k8s_yaml/kpl-launcher/deployment.yaml /tmp/deployment-$date.yaml
sed -i s@hub.kce.ksyun.com/aivc/volcanosh/vc-controller-manager:latest@harbor_host/k8s/vc-controller-manager:latest@g /workspace/seetaas/src/kpl-launcher/k8s_yaml/volcano/volcano-development.yaml
sed -i s@IMAGE_NAME@harbor_host/k8s/$PRI_IMAGE_NAME@g /workspace/seetaas/src/kpl-launcher/k8s_yaml/kpl-launcher/deployment.yaml sed -i s@hub.kce.ksyun.com/aivc/volcanosh/vc-scheduler:latest@harbor_host/k8s/vc-scheduler:latest@g /tmp/volcano-development-$date.yaml
sed -i s@hub.kce.ksyun.com/aivc/volcanosh/vc-webhook-manager:latest@harbor_host/k8s/vc-webhook-manager:latest@g /tmp/volcano-development-$date.yaml
sed -i s@hub.kce.ksyun.com/aivc/volcanosh/vc-controller-manager:latest@harbor_host/k8s/vc-controller-manager:latest@g /tmp/volcano-development-$date.yaml
sed -i s@IMAGE_NAME@harbor_host/k8s/$PRI_IMAGE_NAME@g /tmp/deployment-$date.yaml
} }
###################################################################### ######################################################################
delete_server () { delete_server () {
kubectl delete -f k8s_yaml/kpl-ssl-configmap.yaml kubectl delete -f $workspace/src/kpl-launcher/k8s_yaml/kpl-ssl-configmap.yaml
kubectl delete -f k8s_yaml/kpl-ssl-configmap-autodl.yaml kubectl delete -f $workspace/src/kpl-launcher/k8s_yaml/kpl-ssl-configmap-autodl.yaml
kubectl delete -f k8s_yaml/volcano/ && sleep 2 kubectl delete -f $workspace/src/kpl-launcher/k8s_yaml/volcano/ && sleep 2
kubectl delete -f k8s_yaml/kpl-launcher/ && sleep 2 kubectl delete -f $workspace/src/kpl-launcher/k8s_yaml/kpl-launcher/ && sleep 2
kubectl delete secrets -n volcano-system volcano-admission-secret kubectl delete secrets -n volcano-system volcano-admission-secret
} }
create_server () { create_server () {
kubectl apply -f k8s_yaml/kpl-ssl-configmap.yaml kubectl apply -f $workspace/src/kpl-launcher/k8s_yaml/kpl-ssl-configmap.yaml
kubectl apply -f k8s_yaml/kpl-ssl-configmap-autodl.yaml kubectl apply -f $workspace/src/kpl-launcher/k8s_yaml/kpl-ssl-configmap-autodl.yaml
kubectl apply -f k8s_yaml/volcano/ && sleep 3 kubectl apply -f /tmp/volcano-development-$date.yaml && sleep 3 #在/tmp目录下创建volcano和kpl-launcher服务
kubectl apply -f k8s_yaml/kpl-launcher/ && sleep 3 kubectl apply -f /tmp/deployment-$date.yaml && sleep 3
} }
redeploy_all () { redeploy_all () {
delete_server delete_server
sed_image_name sed_image_name
create_server create_server
recover_image_name
} }
private_deploy () { private_deploy () {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!