volcano.sh/volcano@v1.9.0/hack/local-up-volcano.sh (about)

     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  VOLCANO_NAMESPACE=${VOLCANO_NAMESPACE:-"volcano-system"}
    23  IMAGE_PREFIX=volcanosh
    24  TAG=${TAG:-`git rev-parse --verify HEAD`}
    25  RELEASE_DIR=_output/release
    26  RELEASE_FOLDER=${VK_ROOT}/${RELEASE_DIR}
    27  YAML_FILENAME=volcano-${TAG}.yaml
    28  
    29  
    30  # prepare deploy yaml and docker images
    31  function prepare {
    32    echo "Preparing..."
    33    install-helm
    34  
    35    echo "Building docker images"
    36    make images
    37  }
    38  
    39  
    40  function install-volcano {
    41    # TODO: add a graceful way waiting for all crd ready
    42    kubectl create namespace volcano-system 
    43    helm install volcano ${VK_ROOT}/installer/helm/chart/volcano --namespace volcano-system \
    44    --set basic.image_tag_version=${TAG} \
    45    --set basic.image_pull_policy=IfNotPresent 
    46  }
    47  
    48  function uninstall-volcano {
    49    kubectl delete -f ${VK_ROOT}/installer/helm/chart/volcano/templates/scheduling_v1beta1_queue.yaml
    50    kubectl delete -f ${RELEASE_FOLDER}/${YAML_FILENAME}
    51  }
    52  
    53  # clean up
    54  function cleanup {
    55    uninstall-volcano
    56  
    57    if [ "${INSTALL_MODE}" == "kind" ]; then
    58      echo "Running kind: [kind delete cluster ${CLUSTER_CONTEXT}]"
    59      kind delete cluster ${CLUSTER_CONTEXT}
    60    fi
    61  }
    62  
    63  echo $* | grep -E -q "\-\-help|\-h"
    64  if [[ $? -eq 0 ]]; then
    65    echo "Customize the kind-cluster name:
    66  
    67      export CLUSTER_NAME=<custom cluster name>  # default: volcano
    68  
    69  Customize kind options other than --name:
    70  
    71      export KIND_OPT=<kind options>
    72  
    73  Using existing kubernetes cluster rather than starting a kind custer:
    74  
    75      export INSTALL_MODE=existing
    76  
    77  Cleanup all installation:
    78  
    79      ./hack/local-up-volcano.sh -q
    80  "
    81    exit 0
    82  fi
    83  
    84  
    85  echo $* | grep -E -q "\-\-quit|\-q"
    86  if [[ $? -eq 0 ]]; then
    87    cleanup
    88    exit 0
    89  fi
    90  
    91  source "${VK_ROOT}/hack/lib/install.sh"
    92  
    93  check-prerequisites
    94  
    95  prepare
    96  
    97  if [ "${INSTALL_MODE}" == "kind" ]; then
    98    kind-up-cluster
    99    export KUBECONFIG=${HOME}/.kube/config
   100  fi
   101  
   102  install-volcano