volcano.sh/volcano@v1.9.0/hack/lib/install.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  # spin up cluster with kind command
    18  function kind-up-cluster {
    19    check-kind
    20  
    21    echo "Running kind: [kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}]"
    22    kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}
    23  
    24    echo
    25    check-images
    26  
    27    echo
    28    echo "Loading docker images into kind cluster"
    29    kind load docker-image ${IMAGE_PREFIX}/vc-controller-manager:${TAG} ${CLUSTER_CONTEXT}
    30    kind load docker-image ${IMAGE_PREFIX}/vc-scheduler:${TAG} ${CLUSTER_CONTEXT}
    31    kind load docker-image ${IMAGE_PREFIX}/vc-webhook-manager:${TAG} ${CLUSTER_CONTEXT}
    32  }
    33  
    34  # check if the required images exist
    35  function check-images {
    36    echo "Checking whether the required images exist"
    37    docker image inspect "${IMAGE_PREFIX}/vc-controller-manager:${TAG}" > /dev/null
    38    if [[ $? -ne 0 ]]; then
    39      echo -e "\033[31mERROR\033[0m: ${IMAGE_PREFIX}/vc-controller-manager:${TAG} does not exist"
    40      exit 1
    41    fi
    42    docker image inspect "${IMAGE_PREFIX}/vc-scheduler:${TAG}" > /dev/null
    43    if [[ $? -ne 0 ]]; then
    44      echo -e "\033[31mERROR\033[0m: ${IMAGE_PREFIX}/vc-scheduler:${TAG} does not exist"
    45      exit 1
    46    fi
    47    docker image inspect "${IMAGE_PREFIX}/vc-webhook-manager:${TAG}" > /dev/null
    48    if [[ $? -ne 0 ]]; then
    49      echo -e "\033[31mERROR\033[0m: ${IMAGE_PREFIX}/vc-webhook-manager:${TAG} does not exist"
    50      exit 1
    51    fi
    52  }
    53  
    54  # check if kubectl installed
    55  function check-prerequisites {
    56    echo "Checking prerequisites"
    57    which kubectl >/dev/null 2>&1
    58    if [[ $? -ne 0 ]]; then
    59      echo -e "\033[31mERROR\033[0m: kubectl not installed"
    60      exit 1
    61    else
    62      echo -n "Found kubectl, version: " && kubectl version --short --client
    63    fi
    64  }
    65  
    66  # check if kind installed
    67  function check-kind {
    68    echo "Checking kind"
    69    which kind >/dev/null 2>&1
    70    if [[ $? -ne 0 ]]; then
    71      echo "Installing kind ..."
    72      go install sigs.k8s.io/kind@v0.21.0
    73    else
    74      echo -n "Found kind, version: " && kind version
    75    fi
    76  }
    77  
    78  # install helm if not installed
    79  function install-helm {
    80    echo "Checking helm"
    81    which helm >/dev/null 2>&1
    82    if [[ $? -ne 0 ]]; then
    83      echo "Installing helm via script"
    84      HELM_TEMP_DIR=$(mktemp -d)
    85      curl -fsSL -o ${HELM_TEMP_DIR}/get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
    86      chmod 700 ${HELM_TEMP_DIR}/get_helm.sh && ${HELM_TEMP_DIR}/get_helm.sh
    87    else
    88      echo -n "Found helm, version: " && helm version
    89    fi
    90  }
    91  
    92  function install-ginkgo-if-not-exist {
    93    echo "Checking ginkgo"
    94    which ginkgo >/dev/null 2>&1
    95    if [[ $? -ne 0 ]]; then
    96      echo "Installing ginkgo ..."
    97      go install github.com/onsi/ginkgo/v2/ginkgo
    98    else
    99      echo -n "Found ginkgo, version: " && ginkgo version
   100    fi
   101  }