update-federation-swagger-spec.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. # Script to fetch latest swagger spec from federation-apiserver
  16. # Puts the updated spec at federation/apis/swagger-spec/
  17. set -o errexit
  18. set -o nounset
  19. set -o pipefail
  20. cat << __EOF__
  21. Note: This assumes that the 'types_swagger_doc_generated.go' file has been
  22. updated for all API group versions. If you are unsure, please run
  23. hack/update-generated-swagger-docs.sh and
  24. hack/update-federation-generated-swagger-docs.sh first.
  25. __EOF__
  26. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
  27. SWAGGER_ROOT_DIR="${KUBE_ROOT}/federation/apis/swagger-spec"
  28. source "${KUBE_ROOT}/hack/lib/init.sh"
  29. kube::golang::setup_env
  30. make -C "${KUBE_ROOT}" WHAT="cmd/hyperkube"
  31. function cleanup()
  32. {
  33. [[ -n ${APISERVER_PID-} ]] && kill ${APISERVER_PID} 1>&2 2>/dev/null
  34. kube::etcd::cleanup
  35. kube::log::status "Clean up complete"
  36. }
  37. trap cleanup EXIT SIGINT
  38. kube::golang::setup_env
  39. ETCD_HOST=${ETCD_HOST:-127.0.0.1}
  40. ETCD_PORT=${ETCD_PORT:-2379}
  41. API_PORT=${API_PORT:-8050}
  42. API_HOST=${API_HOST:-127.0.0.1}
  43. kube::etcd::start
  44. # Start federation-apiserver
  45. kube::log::status "Starting federation-apiserver"
  46. sudo -E "${KUBE_OUTPUT_HOSTBIN}/hyperkube" federation-apiserver \
  47. --insecure-bind-address="${API_HOST}" \
  48. --bind-address="${API_HOST}" \
  49. --insecure-port="${API_PORT}" \
  50. --etcd-servers="http://${ETCD_HOST}:${ETCD_PORT}" \
  51. --advertise-address="10.10.10.10" \
  52. --service-cluster-ip-range="10.0.0.0/24" >/tmp/swagger-federation-api-server.log 2>&1 &
  53. APISERVER_PID=$!
  54. kube::util::wait_for_url "${API_HOST}:${API_PORT}/" "apiserver: "
  55. SWAGGER_API_PATH="${API_HOST}:${API_PORT}/swaggerapi/"
  56. DEFAULT_GROUP_VERSIONS="v1 extensions/v1beta1 federation/v1beta1"
  57. VERSIONS=${VERSIONS:-$DEFAULT_GROUP_VERSIONS}
  58. kube::log::status "Updating " ${SWAGGER_ROOT_DIR}
  59. SWAGGER_API_PATH="${SWAGGER_API_PATH}" SWAGGER_ROOT_DIR="${SWAGGER_ROOT_DIR}" VERSIONS="${VERSIONS}" kube::util::fetch-swagger-spec
  60. kube::log::status "SUCCESS"
  61. # ex: ts=2 sw=2 et filetype=sh