kube-push.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. # Push a new release to the cluster.
  16. #
  17. # This will find the release tar, cause it to be downloaded, unpacked, installed
  18. # and enacted.
  19. set -o errexit
  20. set -o nounset
  21. set -o pipefail
  22. echo "kube-push.sh is currently broken; see https://github.com/kubernetes/kubernetes/issues/17397"
  23. exit 1
  24. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
  25. if [ -f "${KUBE_ROOT}/cluster/env.sh" ]; then
  26. source "${KUBE_ROOT}/cluster/env.sh"
  27. fi
  28. source "${KUBE_ROOT}/cluster/kube-util.sh"
  29. function usage() {
  30. echo "${0} [-m|-n <node id>] <version>"
  31. echo " Updates Kubernetes binaries. Can be done for all components (by default), master(-m) or specified node(-n)."
  32. echo " If the version is not specified will try to use local binaries."
  33. echo " Warning: upgrading single node is experimental"
  34. }
  35. push_to_master=false
  36. push_to_node=false
  37. while getopts "mn:h" opt; do
  38. case ${opt} in
  39. m)
  40. push_to_master=true;;
  41. n)
  42. push_to_node=true
  43. node_id="$OPTARG";;
  44. h)
  45. usage
  46. exit 0;;
  47. \?)
  48. echo "Invalid option: -$OPTARG" >&2
  49. usage
  50. exit 1;;
  51. esac
  52. done
  53. shift $((OPTIND-1))
  54. if [[ "${push_to_master}" == "true" ]] && [[ "${push_to_node}" == "true" ]]; then
  55. echo "Only one of options -m -n should be specified"
  56. usage
  57. exit 1
  58. fi
  59. verify-prereqs
  60. KUBE_VERSION=${1-}
  61. if [[ "${push_to_master}" == "false" ]] && [[ "${push_to_node}" == "false" ]]; then
  62. echo "Updating cluster using provider: $KUBERNETES_PROVIDER"
  63. kube-push
  64. fi
  65. if [[ "${push_to_master}" == "true" ]]; then
  66. echo "Updating master to version ${KUBE_VERSION:-"dev"}"
  67. prepare-push false
  68. push-master
  69. fi
  70. if [[ "${push_to_node}" == "true" ]]; then
  71. echo "Updating node $node_id to version ${KUBE_VERSION:-"dev"}"
  72. prepare-push true
  73. push-node $node_id
  74. fi
  75. echo "Validating cluster post-push..."
  76. "${KUBE_ROOT}/cluster/validate-cluster.sh"
  77. echo "Done"