1
1
#! /bin/bash
2
2
3
- export VK_ROOT=$( dirname " ${BASH_SOURCE} " ) /..
3
+ export VK_ROOT=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) /..
4
4
export VK_BIN=${VK_ROOT} /_output/bin
5
5
export LOG_LEVEL=3
6
6
export SHOW_VOLCANO_LOGS=${SHOW_VOLCANO_LOGS:- 1}
7
7
8
- if [ " ${CLUSTER_NAME} xxx" != " xxx" ]; then
8
+ if [[ " ${CLUSTER_NAME} xxx" != " xxx" ] ]; then
9
9
export CLUSTER_CONTEXT=" --name ${CLUSTER_NAME} "
10
+ else
11
+ export CLUSTER_CONTEXT=" --name integration"
10
12
fi
11
13
12
- export KIND_OPT=${KIND_OPT:= " --image kindest/node:v1.13.2 --config ${VK_ROOT} /hack/e2e-kind-config.yaml" }
13
-
14
- export KIND_IMAGE=$( echo ${KIND_OPT} | grep -E -o " image \w+\/[^ ]*" | sed " s/image //" )
14
+ export KIND_OPT=${KIND_OPT:= " --config ${VK_ROOT} /hack/e2e-kind-config.yaml" }
15
15
16
16
# check if kind installed
17
17
function check-prerequisites {
18
18
echo " checking prerequisites"
19
19
which kind > /dev/null 2>&1
20
- if [ $? -ne 0 ]; then
20
+ if [[ $? -ne 0 ] ]; then
21
21
echo " kind not installed, exiting."
22
22
exit 1
23
23
else
24
24
echo -n " found kind, version: " && kind version
25
25
fi
26
26
27
27
which kubectl > /dev/null 2>&1
28
- if [ $? -ne 0 ]; then
28
+ if [[ $? -ne 0 ] ]; then
29
29
echo " kubectl not installed, exiting."
30
30
exit 1
31
31
else
32
32
echo -n " found kubectl, " && kubectl version --short --client
33
33
fi
34
34
}
35
35
36
- # check if the images that kind use exists.
37
- function check-kind-image {
38
- docker images | awk ' {print $1":"$2}' | grep -q " ${KIND_IMAGE} "
39
- if [ $? -ne 0 ]; then
40
- echo " image: ${KIND_IMAGE} not found."
41
- exit 1
42
- fi
43
- }
44
-
45
36
# spin up cluster with kind command
46
37
function kind-up-cluster {
47
38
check-prerequisites
48
- check-kind-image
49
39
echo " Running kind: [kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT} ]"
50
40
kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}
51
41
}
52
42
53
43
function install-volcano {
54
- kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT} /installer/chart/volcano-init/templates/scheduling_v1alpha1_podgroup.yaml
55
- kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT} /installer/chart/volcano-init/templates/scheduling_v1alpha1_queue.yaml
56
- kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT} /installer/chart/volcano-init/templates/batch_v1alpha1_job.yaml
57
- kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT} /installer/chart/volcano-init/templates/bus_v1alpha1_command.yaml
58
-
59
- # TODO: make vk-controllers and vk-scheduler run in container / in k8s
60
- # start controller
61
- nohup ${VK_BIN} /vk-controllers --kubeconfig ${KUBECONFIG} --logtostderr --v ${LOG_LEVEL} > controller.log 2>&1 &
62
- echo $! > vk-controllers.pid
63
-
64
- # start scheduler
65
- nohup ${VK_BIN} /vk-scheduler --kubeconfig ${KUBECONFIG} --scheduler-conf=example/kube-batch-conf.yaml --logtostderr --v ${LOG_LEVEL} > scheduler.log 2>&1 &
66
- echo $! > vk-scheduler.pid
44
+ echo " Preparing helm tiller service account"
45
+ kubectl create serviceaccount --namespace kube-system tiller
46
+ kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
47
+
48
+ echo " Install helm via script and waiting tiller becomes ready"
49
+ curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh
50
+ # TODO: There are some issue with helm's latest version, remove '--version' when it get fixed.
51
+ chmod 700 get_helm.sh && ./get_helm.sh --version v2.13.0
52
+ helm init --service-account tiller --kubeconfig ${KUBECONFIG} --wait
53
+
54
+ echo " Loading docker images into kind cluster"
55
+ kind load docker-image ${IMAGE} -controllers:${TAG} ${CLUSTER_CONTEXT}
56
+ kind load docker-image ${IMAGE} -scheduler:${TAG} ${CLUSTER_CONTEXT}
57
+ kind load docker-image ${IMAGE} -admission:${TAG} ${CLUSTER_CONTEXT}
58
+
59
+ echo " Install volcano plugin into cluster...."
60
+ helm plugin install --kubeconfig ${KUBECONFIG} installer/chart/volcano/plugins/gen-admission-secret
61
+ helm gen-admission-secret --service integration-admission-service --namespace kube-system
62
+
63
+ echo " Install volcano chart"
64
+ helm install installer/chart/volcano --namespace kube-system --name integration --kubeconfig ${KUBECONFIG}
67
65
}
68
66
69
67
function uninstall-volcano {
70
- kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT} /installer/chart/volcano-init/templates/scheduling_v1alpha1_podgroup.yaml
71
- kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT} /installer/chart/volcano-init/templates/scheduling_v1alpha1_queue.yaml
72
- kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT} /installer/chart/volcano-init/templates/batch_v1alpha1_job.yaml
73
- kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT} /installer/chart/volcano-init/templates/bus_v1alpha1_command.yaml
74
-
75
- kill -9 $( cat vk-controllers.pid)
76
- kill -9 $( cat vk-scheduler.pid)
77
- rm vk-controllers.pid vk-scheduler.pid
68
+ helm delete integration --purge --kubeconfig ${KUBECONFIG}
78
69
}
79
70
80
71
# clean up
@@ -84,26 +75,17 @@ function cleanup {
84
75
echo " Running kind: [kind delete cluster ${CLUSTER_CONTEXT} ]"
85
76
kind delete cluster ${CLUSTER_CONTEXT}
86
77
87
- if [ ${SHOW_VOLCANO_LOGS} -eq 1 ]; then
88
- echo " ===================================================================================="
89
- echo " =============================>>>>> Scheduler Logs <<<<<============================="
90
- echo " ===================================================================================="
91
-
92
- cat scheduler.log
93
-
94
- echo " ===================================================================================="
95
- echo " =============================>>>>> Controller Logs <<<<<============================"
96
- echo " ===================================================================================="
97
-
98
- cat controller.log
78
+ if [[ ${SHOW_VOLCANO_LOGS} -eq 1 ]]; then
79
+ # TODO: Add volcano logs support in future.
80
+ echo " Volcano logs are currently not supported."
99
81
fi
100
82
}
101
83
102
84
echo $* | grep -E -q " \-\-help|\-h"
103
- if [ $? -eq 0 ]; then
85
+ if [[ $? -eq 0 ] ]; then
104
86
echo " Customize the kind-cluster name:
105
87
106
- export CLUSTER_NAME=<custom cluster name>
88
+ export CLUSTER_NAME=<custom cluster name> # default: integration
107
89
108
90
Customize kind options other than --name:
109
91
@@ -122,7 +104,7 @@ trap cleanup EXIT
122
104
123
105
kind-up-cluster
124
106
125
- KUBECONFIG=" $( kind get kubeconfig-path ${CLUSTER_CONTEXT} ) "
107
+ export KUBECONFIG=" $( kind get kubeconfig-path ${CLUSTER_CONTEXT} ) "
126
108
127
109
install-volcano
128
110
0 commit comments