kube-util.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. # This script will source the default skeleton helper functions, then sources
  16. # cluster/${KUBERNETES_PROVIDER}/util.sh where KUBERNETES_PROVIDER, if unset,
  17. # will use its default value (gce).
  18. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
  19. source "${KUBE_ROOT}/cluster/skeleton/util.sh"
  20. if [[ -n "${KUBERNETES_CONFORMANCE_TEST:-}" ]]; then
  21. KUBERNETES_PROVIDER=""
  22. else
  23. KUBERNETES_PROVIDER="${KUBERNETES_PROVIDER:-gce}"
  24. fi
  25. PROVIDER_UTILS="${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
  26. if [ -f ${PROVIDER_UTILS} ]; then
  27. source "${PROVIDER_UTILS}"
  28. fi
  29. # Federation utils
  30. # Should NOT be called within the global scope, unless setting the desired global zone vars
  31. # This function is currently NOT USED in the global scope
  32. function set-federation-zone-vars {
  33. zone="$1"
  34. export OVERRIDE_CONTEXT="federation-e2e-${KUBERNETES_PROVIDER}-$zone"
  35. echo "Setting zone vars to: $OVERRIDE_CONTEXT"
  36. if [[ "$KUBERNETES_PROVIDER" == "gce" ]];then
  37. export KUBE_GCE_ZONE="$zone"
  38. # gcloud has a 61 character limit, and for firewall rules this
  39. # prefix gets appended to itself, with some extra information
  40. # need tot keep it short
  41. export KUBE_GCE_INSTANCE_PREFIX="${USER}-${zone}"
  42. elif [[ "$KUBERNETES_PROVIDER" == "gke" ]];then
  43. export CLUSTER_NAME="${USER}-${zone}"
  44. elif [[ "$KUBERNETES_PROVIDER" == "aws" ]];then
  45. export KUBE_AWS_ZONE="$zone"
  46. export KUBE_AWS_INSTANCE_PREFIX="${USER}-${zone}"
  47. else
  48. echo "Provider \"${KUBERNETES_PROVIDER}\" is not supported"
  49. exit 1
  50. fi
  51. }