hyperkube 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/env bash
  2. # Copyright 2019 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. set -o errexit
  16. set -o nounset
  17. set -o pipefail
  18. BINS=(
  19. kube-apiserver
  20. kube-controller-manager
  21. kube-proxy
  22. kube-scheduler
  23. kubectl
  24. kubelet
  25. )
  26. function array_contains() {
  27. local search="$1"
  28. local element
  29. shift
  30. for element; do
  31. if [[ "${element}" == "${search}" ]]; then
  32. return 0
  33. fi
  34. done
  35. return 1
  36. }
  37. function print_usage() {
  38. cat <<EOF
  39. Usage:
  40. $(basename "$0") [command]
  41. Available Commands:
  42. help Help about any command
  43. kube-apiserver
  44. kube-controller-manager
  45. kube-proxy
  46. kube-scheduler
  47. kubectl kubectl controls the Kubernetes cluster manager
  48. kubelet
  49. EOF
  50. exit 0
  51. }
  52. function main() {
  53. if [[ "$#" -lt 1 || "${1:-}" == "--help" || "${1:-}" == "help" ]]; then
  54. print_usage
  55. fi
  56. if ! array_contains "$1" "${BINS[@]}"; then
  57. echo "$1: command not supported"
  58. print_usage
  59. fi
  60. command=${1}
  61. shift
  62. if ! command -v "${command}" &>/dev/null; then
  63. echo "${command}: command not found"
  64. exit 1
  65. fi
  66. exec "${command}" "${@}"
  67. }
  68. main "${@}"