vttablet-down.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. # Copyright 2015 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # This is an example script that tears down the vttablet pods started by
  16. # vttablet-up.sh.
  17. set -e
  18. script_root=`dirname "${BASH_SOURCE}"`
  19. source $script_root/env.sh
  20. server=$(get_vtctld_addr)
  21. # Delete the pods for all shards
  22. CELLS=${CELLS:-'test'}
  23. keyspace='test_keyspace'
  24. SHARDS=${SHARDS:-'0'}
  25. TABLETS_PER_SHARD=${TABLETS_PER_SHARD:-5}
  26. UID_BASE=${UID_BASE:-100}
  27. num_shards=`echo $SHARDS | tr "," " " | wc -w`
  28. uid_base=$UID_BASE
  29. for shard in `seq 1 $num_shards`; do
  30. cell_index=0
  31. for cell in `echo $CELLS | tr "," " "`; do
  32. for uid_index in `seq 0 $(($TABLETS_PER_SHARD-1))`; do
  33. uid=$[$uid_base + $uid_index + $cell_index]
  34. printf -v alias '%s-%010d' $cell $uid
  35. echo "Deleting pod for tablet $alias..."
  36. $KUBECTL delete pod vttablet-$uid
  37. done
  38. let cell_index=cell_index+100000000
  39. done
  40. let uid_base=uid_base+100
  41. done