env.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright 2015 The Kubernetes Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # This is an include file used by the other scripts in this directory.
  15. # Most clusters will just be accessed with 'kubectl' on $PATH.
  16. # However, some might require a different command. For example, GKE required
  17. # KUBECTL='gcloud beta container kubectl' for a while. Now that most of our
  18. # use cases just need KUBECTL=kubectl, we'll make that the default.
  19. KUBECTL=${KUBECTL:-kubectl}
  20. # This should match the nodePort in vtctld-service.yaml
  21. VTCTLD_PORT=${VTCTLD_PORT:-30001}
  22. # Customizable parameters
  23. SHARDS=${SHARDS:-'-80,80-'}
  24. TABLETS_PER_SHARD=${TABLETS_PER_SHARD:-2}
  25. RDONLY_COUNT=${RDONLY_COUNT:-0}
  26. MAX_TASK_WAIT_RETRIES=${MAX_TASK_WAIT_RETRIES:-300}
  27. MAX_VTTABLET_TOPO_WAIT_RETRIES=${MAX_VTTABLET_TOPO_WAIT_RETRIES:-180}
  28. VTTABLET_TEMPLATE=${VTTABLET_TEMPLATE:-'vttablet-pod-template.yaml'}
  29. VTGATE_TEMPLATE=${VTGATE_TEMPLATE:-'vtgate-controller-template.yaml'}
  30. VTGATE_COUNT=${VTGATE_COUNT:-1}
  31. CELLS=${CELLS:-'test'}
  32. ETCD_REPLICAS=3
  33. VTGATE_REPLICAS=$VTGATE_COUNT
  34. # Get the ExternalIP of any node.
  35. get_node_ip() {
  36. $KUBECTL get -o template -t '{{range (index .items 0).status.addresses}}{{if eq .type "ExternalIP"}}{{.address}}{{end}}{{end}}' nodes
  37. }
  38. # Try to find vtctld address if not provided.
  39. get_vtctld_addr() {
  40. if [ -z "$VTCTLD_ADDR" ]; then
  41. node_ip=$(get_node_ip)
  42. if [ -n "$node_ip" ]; then
  43. VTCTLD_ADDR="$node_ip:$VTCTLD_PORT"
  44. fi
  45. fi
  46. echo "$VTCTLD_ADDR"
  47. }
  48. config_file=`dirname "${BASH_SOURCE}"`/config.sh
  49. if [ ! -f $config_file ]; then
  50. echo "Please run ./configure.sh first to generate config.sh file."
  51. exit 1
  52. fi
  53. source $config_file