stopall.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. ##############################################################################
  3. #
  4. # HPCC SYSTEMS software Copyright (C) 2020 HPCC Systems®.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. ##############################################################################
  18. # Utility script for stopping a local cluster started by startall.sh
  19. wait=0
  20. force=0
  21. CLUSTERNAME=mycluster
  22. UNINSTALL_ELK=1
  23. while [ "$#" -gt 0 ]; do
  24. arg=$1
  25. case "${arg}" in
  26. -w) wait=1
  27. ;;
  28. -f) force=1
  29. ;;
  30. -n) shift
  31. CLUSTERNAME=$1
  32. ;;
  33. -e) UNINSTALL_ELK=0
  34. echo "elastic4hpcclogs will not be stopped..."
  35. ;;
  36. *) echo "Usage: stoptall.sh [options]"
  37. echo " -w Wait for all pods to terminate"
  38. echo " -e Suppress deletion of elastic4hpcclogs"
  39. exit
  40. ;;
  41. esac
  42. shift
  43. done
  44. helm uninstall $CLUSTERNAME
  45. helm uninstall localfile
  46. helm uninstall myprometheus4hpccmetrics
  47. kubectl delete jobs --all
  48. kubectl delete networkpolicy --all
  49. if [[ $UNINSTALL_ELK == 1 ]] ; then
  50. echo "Uninstalling myelastic4hpcclogs:"
  51. helm uninstall myelastic4hpcclogs
  52. echo "Deleting Elasticsearch PVC..."
  53. kubectl delete pvc elasticsearch-master-elasticsearch-master-0
  54. fi
  55. if [[ $force == 1 ]] ; then
  56. sleep 1
  57. for f in `kubectl get pods | grep -v ^NAME | awk '{print $1}'` ; do
  58. kubectl delete pod $f --force --grace-period=0
  59. done
  60. fi
  61. if [[ $wait == 1 ]] ; then
  62. sleep 2
  63. while (kubectl get pods | grep -q ^NAME) ; do
  64. echo Waiting...
  65. sleep 2
  66. done
  67. fi