Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add one click install script #345

Merged
merged 6 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# 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.

BIN_DIR=_output/bin
RELEASE_DIR=_output/release
REL_OSARCH=linux/amd64
REPO_PATH=volcano.sh/volcano
IMAGE_PREFIX=volcanosh/vc
TAG=latest
# If tag not explicitly set in users default to the git sha.
TAG ?= $(shell git rev-parse --verify HEAD)
RELEASE_VER=v0.1
GitSHA=`git rev-parse HEAD`
Date=`date "+%Y-%m-%d %H:%M:%S"`
Expand Down
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,16 @@ You can watch industry experts talking about Volcano in different International

- Kubernetes 1.12+ with CRD support

### Install with YAML files

Install volcano k8s resources
You can try volcano by one the following two ways.

```
kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/master/installer/volcano-development.yaml
```

Install `default-queue` for volcano scheduler, note that the crd resources should be ready before this.
### Install with YAML files

```
kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/master/installer/helm/chart/volcano/templates/default-queue.yaml
Install volcano on a existing Kubernetes cluster.

```
kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/master/installer/volcano-development.yaml
```

Enjoy! Volcano will create the following resources in `volcano-system` namespace.
Expand Down Expand Up @@ -109,6 +106,14 @@ job.batch/volcano-admission-init 1/1 48s 96s

```

### Install from code

If you have no kubernetes cluster, try one click install from code base:

```bash
./hack/local-up-volcano.sh
```


## Community, discussion, contribution, and support

Expand Down
67 changes: 67 additions & 0 deletions hack/lib/install.sh
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
}
102 changes: 102 additions & 0 deletions hack/local-up-volcano.sh
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the clusters other than kind cluster, how can user deploy the images into the cluster?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question: we can not know their registry. If they use one node development env, the image is on the host. But if it is a multi-node cluster, we can not do that for users.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to mention this in the document or just support kind cluster, since for the other cases, they can deploy volcano via the installation guide.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SG

kind-up-cluster
export KUBECONFIG="$(kind get kubeconfig-path ${CLUSTER_CONTEXT})"
fi

install-volcano


32 changes: 4 additions & 28 deletions hack/run-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,10 @@ export CLUSTER_CONTEXT="--name ${CLUSTER_NAME}"

export KIND_OPT=${KIND_OPT:=" --config ${VK_ROOT}/hack/e2e-kind-config.yaml"}

# check if kind installed
function check-prerequisites {
echo "checking prerequisites"
which kind >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "kind not installed, exiting."
exit 1
else
echo -n "found kind, version: " && kind version
fi

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
}

# spin up cluster with kind command
function kind-up-cluster {
check-prerequisites
check-kind
echo "Running kind: [kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}]"
kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}
}
Expand All @@ -47,20 +28,13 @@ function install-volcano {
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller

echo "Install helm via script and waiting tiller becomes ready"
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
install-helm
helm init --service-account tiller --kubeconfig ${KUBECONFIG} --wait

echo "Pulling required docker images"
docker pull ${MPI_EXAMPLE_IMAGE}

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}
kind load docker-image ${MPI_EXAMPLE_IMAGE} ${CLUSTER_CONTEXT}

echo "Install volcano chart"
Expand Down Expand Up @@ -115,7 +89,9 @@ if [[ $CLEANUP_CLUSTER -eq 1 ]]; then
trap cleanup EXIT
fi

source "${VK_ROOT}/hack/lib/install.sh"

check-prerequisites
kind-up-cluster

export KUBECONFIG="$(kind get kubeconfig-path ${CLUSTER_CONTEXT})"
Expand Down
17 changes: 16 additions & 1 deletion pkg/scheduler/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import (

"github.com/golang/glog"

v1 "k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/api/scheduling/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand All @@ -45,6 +46,7 @@ import (

"volcano.sh/volcano/cmd/scheduler/app/options"
"volcano.sh/volcano/pkg/apis/scheduling/v1alpha1"
"volcano.sh/volcano/pkg/apis/scheduling/v1alpha2"
kbver "volcano.sh/volcano/pkg/client/clientset/versioned"
"volcano.sh/volcano/pkg/client/clientset/versioned/scheme"
kbschema "volcano.sh/volcano/pkg/client/clientset/versioned/scheme"
Expand Down Expand Up @@ -258,6 +260,19 @@ func newSchedulerCache(config *rest.Config, schedulerName string, defaultQueue s
panic(fmt.Sprintf("failed init eventClient, with err: %v", err))
}

// create default queue
defaultQue := v1alpha2.Queue{
ObjectMeta: metav1.ObjectMeta{
Name: defaultQueue,
},
Spec: v1alpha2.QueueSpec{
Weight: 1,
},
}
if _, err := kbClient.SchedulingV1alpha2().Queues().Create(&defaultQue); err != nil && !apierrors.IsAlreadyExists(err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I have a existing default-queue from the previous version of volcano?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not matter

panic(fmt.Sprintf("failed init default queue, with err: %v", err))
}

sc := &SchedulerCache{
Jobs: make(map[kbapi.JobID]*kbapi.JobInfo),
Nodes: make(map[string]*kbapi.NodeInfo),
Expand Down