-
Notifications
You must be signed in to change notification settings - Fork 993
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from hzxuzhonghu/one-click-install
Add one click install script
- Loading branch information
Showing
6 changed files
with
218 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2019 The Volcano Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# spin up cluster with kind command | ||
function kind-up-cluster { | ||
check-kind | ||
echo "Running kind: [kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}]" | ||
kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT} | ||
|
||
echo "Loading docker images into kind cluster" | ||
kind load docker-image ${IMAGE_PREFIX}-controllers:${TAG} ${CLUSTER_CONTEXT} | ||
kind load docker-image ${IMAGE_PREFIX}-scheduler:${TAG} ${CLUSTER_CONTEXT} | ||
kind load docker-image ${IMAGE_PREFIX}-admission:${TAG} ${CLUSTER_CONTEXT} | ||
} | ||
|
||
|
||
# check if kubectl installed | ||
function check-prerequisites { | ||
echo "checking prerequisites" | ||
which kubectl >/dev/null 2>&1 | ||
if [[ $? -ne 0 ]]; then | ||
echo "kubectl not installed, exiting." | ||
exit 1 | ||
else | ||
echo -n "found kubectl, " && kubectl version --short --client | ||
fi | ||
} | ||
|
||
# check if kind installed | ||
function check-kind { | ||
echo "checking kind" | ||
which kind >/dev/null 2>&1 | ||
if [[ $? -ne 0 ]]; then | ||
echo "installing kind ." | ||
GO111MODULE="on" go get sigs.k8s.io/kind@v0.4.0 | ||
else | ||
echo -n "found kind, version: " && kind version | ||
fi | ||
} | ||
|
||
# install helm if not installed | ||
function install-helm { | ||
echo "checking helm" | ||
which helm >/dev/null 2>&1 | ||
if [[ $? -ne 0 ]]; then | ||
echo "Install helm via script" | ||
HELM_TEMP_DIR=`mktemp -d` | ||
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > ${HELM_TEMP_DIR}/get_helm.sh | ||
#TODO: There are some issue with helm's latest version, remove '--version' when it get fixed. | ||
chmod 700 ${HELM_TEMP_DIR}/get_helm.sh && ${HELM_TEMP_DIR}/get_helm.sh --version v2.13.0 | ||
else | ||
echo -n "found helm, version: " && helm version | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2019 The Volcano Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
VK_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.. | ||
CLUSTER_NAME=${CLUSTER_NAME:-volcano} | ||
CLUSTER_CONTEXT="--name ${CLUSTER_NAME}" | ||
KIND_OPT=${KIND_OPT:-} | ||
INSTALL_MODE=${INSTALL_MODE:-"kind"} | ||
IMAGE_PREFIX=volcanosh/vc | ||
TAG=${TAG:-`git rev-parse --verify HEAD`} | ||
RELEASE_DIR=_output/release | ||
RELEASE_FOLDER=${VK_ROOT}/${RELEASE_DIR} | ||
YAML_FILENAME=volcano-${TAG}.yaml | ||
|
||
|
||
# prepare deploy yaml and docker images | ||
function prepare { | ||
echo "Preparing..." | ||
install-helm | ||
echo "Generating valcano deploy yaml" | ||
make generate-yaml | ||
|
||
echo "Building docker images" | ||
make images | ||
} | ||
|
||
|
||
function install-volcano { | ||
# TODO: add a graceful way waiting for all crd ready | ||
kubectl apply -f ${RELEASE_FOLDER}/${YAML_FILENAME} | ||
} | ||
|
||
function uninstall-volcano { | ||
kubectl delete -f ${VK_ROOT}/installer/helm/chart/volcano/templates/default-queue.yaml | ||
kubectl delete -f ${RELEASE_FOLDER}/${YAML_FILENAME} | ||
} | ||
|
||
# clean up | ||
function cleanup { | ||
uninstall-volcano | ||
|
||
if [ "${INSTALL_MODE}" == "kind" ]; then | ||
echo "Running kind: [kind delete cluster ${CLUSTER_CONTEXT}]" | ||
kind delete cluster ${CLUSTER_CONTEXT} | ||
fi | ||
} | ||
|
||
echo $* | grep -E -q "\-\-help|\-h" | ||
if [[ $? -eq 0 ]]; then | ||
echo "Customize the kind-cluster name: | ||
export CLUSTER_NAME=<custom cluster name> # default: volcano | ||
Customize kind options other than --name: | ||
export KIND_OPT=<kind options> | ||
Using existing kubernetes cluster rather than starting a kind custer: | ||
export INSTALL_MODE=existing | ||
Cleanup all installation: | ||
./hack/local-up-volcano.sh -q | ||
" | ||
exit 0 | ||
fi | ||
|
||
|
||
echo $* | grep -E -q "\-\-quit|\-q" | ||
if [[ $? -eq 0 ]]; then | ||
cleanup | ||
exit 0 | ||
fi | ||
|
||
source "${VK_ROOT}/hack/lib/install.sh" | ||
|
||
check-prerequisites | ||
|
||
prepare | ||
|
||
if [ "${INSTALL_MODE}" == "kind" ]; then | ||
kind-up-cluster | ||
export KUBECONFIG="$(kind get kubeconfig-path ${CLUSTER_CONTEXT})" | ||
fi | ||
|
||
install-volcano | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters