This repository has been archived by the owner on Oct 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbootkube-up
executable file
·65 lines (54 loc) · 2.54 KB
/
bootkube-up
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
#!/bin/bash
set -euo pipefail
MASTER_NODES=2
WORKER_NODES=1
ASSET_FOLDER=$1
createVolume() {
VOLUME=$1-vol.qcow2
qcow-tool create --size=6GiB ${VOLUME}
corectl run -c stable -o --name disk --volume=${VOLUME}
corectl ssh disk "yes | sudo mke2fs -b 1024 -i 1024 -t ext4 -E lazy_itable_init=1 /dev/vda -F"
corectl halt disk
}
bootSeed() {
echo "starting bootkube server"
corectl run -c stable -o --name $1 -N 2 -m 2048 --cloud_config ./${ASSET_FOLDER}/bootkube-user-data.yaml -r $1-vol.qcow2 -F
corectl put ./${ASSET_FOLDER}.zip $1:/home/core/cluster.zip
corectl ssh $1 "sudo mkdir -p /etc/kubernetes && sudo mkdir -p /etc/etcd/tls/etcd"
corectl ssh $1 "unzip cluster.zip && rm cluster.zip && sudo chown -R core:core /home/core/${ASSET_FOLDER}"
corectl ssh $1 "sudo cp /home/core/${ASSET_FOLDER}/tls/etcd-client* /etc/etcd/tls && sudo cp /home/core/${ASSET_FOLDER}/tls/etcd/* /etc/etcd/tls/etcd && sudo chown -R etcd:etcd /etc/etcd && sudo chmod 500 -R /etc/etcd"
corectl ssh $1 "sudo cp /home/core/${ASSET_FOLDER}/auth/kubeconfig /etc/kubernetes/"
corectl ssh $1 "sudo cp /home/core/${ASSET_FOLDER}/tls/ca.crt /etc/kubernetes/ && sudo chown core:core /etc/kubernetes/ca.crt"
}
bootServer() {
echo "Starting $1"
type=$(echo $1 | cut -d '-' -f1)
corectl run -c stable -o --name $1 -N 2 -m 2048 --cloud_config ./${ASSET_FOLDER}/${type}-user-data.yaml -r $1-vol.qcow2 -F
echo "Configuring $1"
corectl put ./${ASSET_FOLDER}/auth/kubeconfig-kubelet $1:/tmp/kubeconfig
corectl put ./${ASSET_FOLDER}/tls/ca.crt $1:/tmp/
corectl ssh $1 "sudo cp /tmp/ca.crt /etc/kubernetes/ && sudo cp /tmp/kubeconfig /etc/kubernetes/ && sudo chown -R core:core /etc/kubernetes/"
}
for (( i=1; i<=${MASTER_NODES}; i++ )); do
createVolume master-$i
done
for (( i=1; i<=${WORKER_NODES}; i++ )); do
createVolume worker-$i
done
echo "generating userdata..."
cp bootkube.yaml ${ASSET_FOLDER}/bootkube-user-data.yaml
sed -i '' "s/ASSETVAR/${ASSET_FOLDER}/g" ${ASSET_FOLDER}/bootkube-user-data.yaml
cp setup.yaml ${ASSET_FOLDER}/master-user-data.yaml
sed -i '' "s/TYPE/master/g" ${ASSET_FOLDER}/master-user-data.yaml
cp setup.yaml ${ASSET_FOLDER}/worker-user-data.yaml
sed -i '' "s/TYPE/edge/g" ${ASSET_FOLDER}/worker-user-data.yaml
sed -i '' '/register-with-taints/d' ${ASSET_FOLDER}/worker-user-data.yaml
zip -r ${ASSET_FOLDER}.zip ${ASSET_FOLDER}
echo "staring seed server..."
bootSeed master-1
for (( i=2; i<=${MASTER_NODES}; i++ )); do
bootServer master-$i
done
for (( i=1; i<=${WORKER_NODES}; i++ )); do
bootServer worker-$i
done