|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2019 The Volcano Authors. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +VK_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.. |
| 18 | +CLUSTER_NAME=${CLUSTER_NAME:-volcano} |
| 19 | +CLUSTER_CONTEXT="--name ${CLUSTER_NAME}" |
| 20 | +KIND_OPT=${KIND_OPT:-} |
| 21 | +INSTALL_MODE=${INSTALL_MODE:-"kind"} |
| 22 | +IMAGE_PREFIX=volcanosh/vc |
| 23 | +TAG=${TAG:-`git rev-parse --verify HEAD`} |
| 24 | +RELEASE_DIR=_output/release |
| 25 | +RELEASE_FOLDER=${VK_ROOT}/${RELEASE_DIR} |
| 26 | +YAML_FILENAME=volcano-${TAG}.yaml |
| 27 | + |
| 28 | + |
| 29 | +# prepare deploy yaml and docker images |
| 30 | +function prepare { |
| 31 | + echo "Preparing..." |
| 32 | + install-helm |
| 33 | + echo "Generating valcano deploy yaml" |
| 34 | + make generate-yaml |
| 35 | + |
| 36 | + echo "Building docker images" |
| 37 | + make images |
| 38 | +} |
| 39 | + |
| 40 | + |
| 41 | +function install-volcano { |
| 42 | + # TODO: add a graceful way waiting for all crd ready |
| 43 | + kubectl apply -f ${RELEASE_FOLDER}/${YAML_FILENAME} |
| 44 | +} |
| 45 | + |
| 46 | +function uninstall-volcano { |
| 47 | + kubectl delete -f ${VK_ROOT}/installer/helm/chart/volcano/templates/default-queue.yaml |
| 48 | + kubectl delete -f ${RELEASE_FOLDER}/${YAML_FILENAME} |
| 49 | +} |
| 50 | + |
| 51 | +# clean up |
| 52 | +function cleanup { |
| 53 | + uninstall-volcano |
| 54 | + |
| 55 | + if [ "${INSTALL_MODE}" == "kind" ]; then |
| 56 | + echo "Running kind: [kind delete cluster ${CLUSTER_CONTEXT}]" |
| 57 | + kind delete cluster ${CLUSTER_CONTEXT} |
| 58 | + fi |
| 59 | +} |
| 60 | + |
| 61 | +echo $* | grep -E -q "\-\-help|\-h" |
| 62 | +if [[ $? -eq 0 ]]; then |
| 63 | + echo "Customize the kind-cluster name: |
| 64 | +
|
| 65 | + export CLUSTER_NAME=<custom cluster name> # default: volcano |
| 66 | +
|
| 67 | +Customize kind options other than --name: |
| 68 | +
|
| 69 | + export KIND_OPT=<kind options> |
| 70 | +
|
| 71 | +Using existing kubernetes cluster rather than starting a kind custer: |
| 72 | +
|
| 73 | + export INSTALL_MODE=existing |
| 74 | +
|
| 75 | +Cleanup all installation: |
| 76 | +
|
| 77 | + ./hack/local-up-volcano.sh -q |
| 78 | +" |
| 79 | + exit 0 |
| 80 | +fi |
| 81 | + |
| 82 | + |
| 83 | +echo $* | grep -E -q "\-\-quit|\-q" |
| 84 | +if [[ $? -eq 0 ]]; then |
| 85 | + cleanup |
| 86 | + exit 0 |
| 87 | +fi |
| 88 | + |
| 89 | +source "${VK_ROOT}/hack/lib/install.sh" |
| 90 | + |
| 91 | +check-prerequisites |
| 92 | + |
| 93 | +prepare |
| 94 | + |
| 95 | +if [ "${INSTALL_MODE}" == "kind" ]; then |
| 96 | + kind-up-cluster |
| 97 | + export KUBECONFIG="$(kind get kubeconfig-path ${CLUSTER_CONTEXT})" |
| 98 | +fi |
| 99 | + |
| 100 | +install-volcano |
| 101 | + |
| 102 | + |
0 commit comments