deploy-back.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. starttime=`date +'%Y-%m-%d %H:%M:%S'`
  2. #mvn clean package -DskipTests
  3. currentTimeStamp=$(cat version.txt)
  4. sed -i "s%#version_num#%$currentTimeStamp%g" deployment_local.yaml
  5. docker build . -t registry.cn-shanghai.aliyuncs.com/ab-inbev-apac/abi-cloud-qr-platform-service:$currentTimeStamp
  6. docker push registry.cn-shanghai.aliyuncs.com/ab-inbev-apac/abi-cloud-qr-platform-service:$currentTimeStamp
  7. kubectl apply -f deployment_local.yaml -n $1
  8. kubectl get pods -n $1 -o wide | grep abi-cloud-qr-platform-service
  9. if [ $2 ] ; then
  10. kubectl apply -f deployment_local.yaml -n $2
  11. kubectl get pods -n $2 -o wide | grep abi-cloud-qr-platform-service
  12. echo __$1__$2"环境发版结束"
  13. else
  14. echo $1"环境发版结束"
  15. fi
  16. sed -i "s%$currentTimeStamp%#version_num#%g" deployment_local.yaml
  17. COUNTER=$(kubectl get pods -n $1 -o wide| grep abi-cloud-qr-platform-service | awk 'END{print NR}')
  18. endtime=`date +'%Y-%m-%d %H:%M:%S'`
  19. start_seconds=$(date --date="$starttime" +%s)
  20. end_seconds=$(date --date="$endtime" +%s)
  21. echo "运行时间: "$((end_seconds-start_seconds))"s"
  22. timeout=0
  23. while [ "$COUNTER" -gt 1 ]; do
  24. sleep 10
  25. COUNTER=$(kubectl get pods -n $1 -o wide| grep abi-cloud-qr-platform-service | awk 'END{print NR}')
  26. kubectl get pods -n $1 -o wide| grep abi-cloud-qr-platform-service
  27. echo $COUNTER
  28. timeout=$(($timeout+10))
  29. if [ "$timeout" -gt 100 ]; then
  30. echo "发版异常,请访问https://cs.console.aliyun.com/"
  31. break
  32. fi
  33. #strin=$(kubectl get pods -n $1 -o wide| grep abi-cloud-qr-platform-service | grep Running | awk '{print$1}')
  34. # kubectl logs --tail 100 -f strin -n $1
  35. done
  36. sh lookLog.sh $1