Skip to content

Commit 4492e66

Browse files
Merge pull request #345 from hzxuzhonghu/one-click-install
Add one click install script
2 parents 0068809 + 1d26a0c commit 4492e66

File tree

6 files changed

+218
-38
lines changed

6 files changed

+218
-38
lines changed

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
# Copyright 2019 The Volcano Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
BIN_DIR=_output/bin
216
RELEASE_DIR=_output/release
317
REL_OSARCH=linux/amd64
418
REPO_PATH=volcano.sh/volcano
519
IMAGE_PREFIX=volcanosh/vc
6-
TAG=latest
20+
# If tag not explicitly set in users default to the git sha.
21+
TAG ?= $(shell git rev-parse --verify HEAD)
722
RELEASE_VER=v0.1
823
GitSHA=`git rev-parse HEAD`
924
Date=`date "+%Y-%m-%d %H:%M:%S"`

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,16 @@ You can watch industry experts talking about Volcano in different International
6666

6767
- Kubernetes 1.12+ with CRD support
6868

69-
### Install with YAML files
7069

71-
Install volcano k8s resources
70+
You can try volcano by one the following two ways.
7271

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

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

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

77+
```
78+
kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/master/installer/volcano-development.yaml
8279
```
8380

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

109+
### Install from code
110+
111+
If you have no kubernetes cluster, try one click install from code base:
112+
113+
```bash
114+
./hack/local-up-volcano.sh
115+
```
116+
112117

113118
## Community, discussion, contribution, and support
114119

hack/lib/install.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
echo "Running kind: [kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}]"
21+
kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}
22+
23+
echo "Loading docker images into kind cluster"
24+
kind load docker-image ${IMAGE_PREFIX}-controllers:${TAG} ${CLUSTER_CONTEXT}
25+
kind load docker-image ${IMAGE_PREFIX}-scheduler:${TAG} ${CLUSTER_CONTEXT}
26+
kind load docker-image ${IMAGE_PREFIX}-admission:${TAG} ${CLUSTER_CONTEXT}
27+
}
28+
29+
30+
# check if kubectl installed
31+
function check-prerequisites {
32+
echo "checking prerequisites"
33+
which kubectl >/dev/null 2>&1
34+
if [[ $? -ne 0 ]]; then
35+
echo "kubectl not installed, exiting."
36+
exit 1
37+
else
38+
echo -n "found kubectl, " && kubectl version --short --client
39+
fi
40+
}
41+
42+
# check if kind installed
43+
function check-kind {
44+
echo "checking kind"
45+
which kind >/dev/null 2>&1
46+
if [[ $? -ne 0 ]]; then
47+
echo "installing kind ."
48+
GO111MODULE="on" go get sigs.k8s.io/kind@v0.4.0
49+
else
50+
echo -n "found kind, version: " && kind version
51+
fi
52+
}
53+
54+
# install helm if not installed
55+
function install-helm {
56+
echo "checking helm"
57+
which helm >/dev/null 2>&1
58+
if [[ $? -ne 0 ]]; then
59+
echo "Install helm via script"
60+
HELM_TEMP_DIR=`mktemp -d`
61+
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > ${HELM_TEMP_DIR}/get_helm.sh
62+
#TODO: There are some issue with helm's latest version, remove '--version' when it get fixed.
63+
chmod 700 ${HELM_TEMP_DIR}/get_helm.sh && ${HELM_TEMP_DIR}/get_helm.sh --version v2.13.0
64+
else
65+
echo -n "found helm, version: " && helm version
66+
fi
67+
}

hack/local-up-volcano.sh

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+

hack/run-e2e-kind.sh

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,10 @@ export CLUSTER_CONTEXT="--name ${CLUSTER_NAME}"
1515

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

18-
# check if kind installed
19-
function check-prerequisites {
20-
echo "checking prerequisites"
21-
which kind >/dev/null 2>&1
22-
if [[ $? -ne 0 ]]; then
23-
echo "kind not installed, exiting."
24-
exit 1
25-
else
26-
echo -n "found kind, version: " && kind version
27-
fi
28-
29-
which kubectl >/dev/null 2>&1
30-
if [[ $? -ne 0 ]]; then
31-
echo "kubectl not installed, exiting."
32-
exit 1
33-
else
34-
echo -n "found kubectl, " && kubectl version --short --client
35-
fi
36-
}
37-
3818
# spin up cluster with kind command
3919
function kind-up-cluster {
4020
check-prerequisites
21+
check-kind
4122
echo "Running kind: [kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}]"
4223
kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}
4324
}
@@ -47,20 +28,13 @@ function install-volcano {
4728
kubectl create serviceaccount --namespace kube-system tiller
4829
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
4930

50-
echo "Install helm via script and waiting tiller becomes ready"
51-
HELM_TEMP_DIR=`mktemp -d`
52-
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > ${HELM_TEMP_DIR}/get_helm.sh
53-
#TODO: There are some issue with helm's latest version, remove '--version' when it get fixed.
54-
chmod 700 ${HELM_TEMP_DIR}/get_helm.sh && ${HELM_TEMP_DIR}/get_helm.sh --version v2.13.0
31+
install-helm
5532
helm init --service-account tiller --kubeconfig ${KUBECONFIG} --wait
5633

5734
echo "Pulling required docker images"
5835
docker pull ${MPI_EXAMPLE_IMAGE}
5936

6037
echo "Loading docker images into kind cluster"
61-
kind load docker-image ${IMAGE_PREFIX}-controllers:${TAG} ${CLUSTER_CONTEXT}
62-
kind load docker-image ${IMAGE_PREFIX}-scheduler:${TAG} ${CLUSTER_CONTEXT}
63-
kind load docker-image ${IMAGE_PREFIX}-admission:${TAG} ${CLUSTER_CONTEXT}
6438
kind load docker-image ${MPI_EXAMPLE_IMAGE} ${CLUSTER_CONTEXT}
6539

6640
echo "Install volcano chart"
@@ -115,7 +89,9 @@ if [[ $CLEANUP_CLUSTER -eq 1 ]]; then
11589
trap cleanup EXIT
11690
fi
11791

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

94+
check-prerequisites
11995
kind-up-cluster
12096

12197
export KUBECONFIG="$(kind get kubeconfig-path ${CLUSTER_CONTEXT})"

pkg/scheduler/cache/cache.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ import (
2323

2424
"github.com/golang/glog"
2525

26-
v1 "k8s.io/api/core/v1"
26+
"k8s.io/api/core/v1"
2727
"k8s.io/api/scheduling/v1beta1"
28+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2829
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2930
"k8s.io/apimachinery/pkg/runtime"
3031
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -45,6 +46,7 @@ import (
4546

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

263+
// create default queue
264+
defaultQue := v1alpha2.Queue{
265+
ObjectMeta: metav1.ObjectMeta{
266+
Name: defaultQueue,
267+
},
268+
Spec: v1alpha2.QueueSpec{
269+
Weight: 1,
270+
},
271+
}
272+
if _, err := kbClient.SchedulingV1alpha2().Queues().Create(&defaultQue); err != nil && !apierrors.IsAlreadyExists(err) {
273+
panic(fmt.Sprintf("failed init default queue, with err: %v", err))
274+
}
275+
261276
sc := &SchedulerCache{
262277
Jobs: make(map[kbapi.JobID]*kbapi.JobInfo),
263278
Nodes: make(map[string]*kbapi.NodeInfo),

0 commit comments

Comments
 (0)