kube-up.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. # Copyright 2014 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. # Bring up a Kubernetes cluster.
  16. #
  17. # If the full release name (gs://<bucket>/<release>) is passed in then we take
  18. # that directly. If not then we assume we are doing development stuff and take
  19. # the defaults in the release config.
  20. set -o errexit
  21. set -o nounset
  22. set -o pipefail
  23. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
  24. if [ -f "${KUBE_ROOT}/cluster/env.sh" ]; then
  25. source "${KUBE_ROOT}/cluster/env.sh"
  26. fi
  27. source "${KUBE_ROOT}/cluster/kube-util.sh"
  28. if [ -z "${ZONE-}" ]; then
  29. echo "... Starting cluster using provider: ${KUBERNETES_PROVIDER}" >&2
  30. else
  31. echo "... Starting cluster in ${ZONE} using provider ${KUBERNETES_PROVIDER}" >&2
  32. fi
  33. echo "... calling verify-prereqs" >&2
  34. verify-prereqs
  35. if [[ "${KUBE_STAGE_IMAGES:-}" == "true" ]]; then
  36. echo "... staging images" >&2
  37. stage-images
  38. fi
  39. echo "... calling kube-up" >&2
  40. kube-up
  41. echo "... calling validate-cluster" >&2
  42. # Override errexit
  43. (validate-cluster) && validate_result="$?" || validate_result="$?"
  44. # We have two different failure modes from validate cluster:
  45. # - 1: fatal error - cluster won't be working correctly
  46. # - 2: weak error - something went wrong, but cluster probably will be working correctly
  47. # We just print an error message in case 2).
  48. if [[ "${validate_result}" == "1" ]]; then
  49. exit 1
  50. elif [[ "${validate_result}" == "2" ]]; then
  51. echo "...ignoring non-fatal errors in validate-cluster" >&2
  52. fi
  53. if [[ "${ENABLE_PROXY:-}" == "true" ]]; then
  54. . /tmp/kube-proxy-env
  55. echo ""
  56. echo "*** Please run the following to add the kube-apiserver endpoint to your proxy white-list ***"
  57. cat /tmp/kube-proxy-env
  58. echo "*** ***"
  59. echo ""
  60. fi
  61. echo -e "Done, listing cluster services:\n" >&2
  62. "${KUBE_ROOT}/cluster/kubectl.sh" cluster-info
  63. echo
  64. exit 0