forked from metal3-io/metal3-dev-env
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_launch_mgmt_cluster.sh
More file actions
executable file
·131 lines (114 loc) · 3.45 KB
/
03_launch_mgmt_cluster.sh
File metadata and controls
executable file
·131 lines (114 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
set -xe
# shellcheck disable=SC1091
source lib/logging.sh
# shellcheck disable=SC1091
source lib/common.sh
eval "$(go env)"
export GOPATH
# Environment variables
# M3PATH : Path to clone the metal3 dev env repo
# BMOPATH : Path to clone the baremetal operator repo
# CAPBMPATH: Path to clone the CAPI operator repo
#
# BMOREPO : Baremetal operator repository URL
# BMOBRANCH : Baremetal operator repository branch to checkout
# CAPBMREPO : CAPI operator repository URL
# CAPBMBRANCH : CAPI repository branch to checkout
# FORCE_REPO_UPDATE : discard existing directories
#
# BMO_RUN_LOCAL : run the baremetal operator locally (not in Kubernetes cluster)
# CAPBM_RUN_LOCAL : run the CAPI operator locally
M3PATH="${GOPATH}/src/github.com/metal3-io"
BMOPATH="${M3PATH}/baremetal-operator"
CAPBMPATH="${M3PATH}/cluster-api-provider-baremetal"
BMOREPO="${BMOREPO:-https://github.com/metal3-io/baremetal-operator.git}"
BMOBRANCH="${BMOBRANCH:-master}"
CAPBMREPO="${CAPBMREPO:-https://github.com/metal3-io/cluster-api-provider-baremetal.git}"
CAPBMBRANCH="${CAPBMBRANCH:-master}"
FORCE_REPO_UPDATE="${FORCE_REPO_UPDATE:-false}"
BMO_RUN_LOCAL="${BMO_RUN_LOCAL:-false}"
CAPBM_RUN_LOCAL="${CAPBM_RUN_LOCAL:-false}"
function clone_repos() {
mkdir -p "${M3PATH}"
if [[ -d ${BMOPATH} && "${FORCE_REPO_UPDATE}" == "true" ]]; then
rm -rf "${BMOPATH}"
fi
if [ ! -d "${BMOPATH}" ] ; then
pushd "${M3PATH}"
git clone "${BMOREPO}"
popd
fi
pushd "${BMOPATH}"
git checkout "${BMOBRANCH}"
git pull -r || true
popd
if [[ -d "${CAPBMPATH}" && "${FORCE_REPO_UPDATE}" == "true" ]]; then
rm -rf "${CAPBMPATH}"
fi
if [ ! -d "${CAPBMPATH}" ] ; then
pushd "${M3PATH}"
git clone "${CAPBMREPO}"
popd
fi
pushd "${CAPBMPATH}"
git checkout "${CAPBMBRANCH}"
git pull -r || true
popd
}
function configure_minikube() {
minikube config set vm-driver kvm2
}
function launch_kind() {
kind create cluster --name=clusterapi
export KUBECONFIG="$(kind get kubeconfig-path --name="clusterapi")" # The interface doesn't appear in the minikube VM with --live,
# so just attach it and make it reboot.
}
function launch_baremetal_operator() {
pushd "${BMOPATH}"
if [ "${BMO_RUN_LOCAL}" = true ]; then
touch bmo.out.log
touch bmo.err.log
make deploy
kubectl scale deployment metal3-baremetal-operator -n metal3 --replicas=0
nohup make run >> bmo.out.log 2>>bmo.err.log &
else
make deploy
fi
popd
}
function make_bm_hosts() {
while read -r name address user password mac; do
go run "${BMOPATH}"/cmd/make-bm-worker/main.go \
-address "$address" \
-password "$password" \
-user "$user" \
-boot-mac "$mac" \
"$name"
done
}
function apply_bm_hosts() {
list_nodes | make_bm_hosts > bmhosts_crs.yaml
kubectl apply -f bmhosts_crs.yaml -n metal3
}
#
# Launch the cluster-api controller manager in the metal3 namespace.
#
function launch_cluster_api() {
pushd "${CAPBMPATH}"
if [ "${CAPBM_RUN_LOCAL}" = true ]; then
touch capbm.out.log
touch capbm.err.log
make deploy
kubectl scale statefulset cluster-api-provider-baremetal-controller-manager -n metal3 --replicas=0
nohup make run >> capbm.out.log 2>> capbm.err.log &
else
make deploy
fi
popd
}
clone_repos
launch_kind
launch_baremetal_operator
apply_bm_hosts
launch_cluster_api