forked from labring/sealos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
join-node-and-nodes.sh
74 lines (58 loc) · 2.81 KB
/
join-node-and-nodes.sh
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
#!/bin/bash
# sh test.sh 1.15.4 pkgurl v3.2.0-alpha.0
# test sealos join command, sealos join --node 192.168.0.2 --nodes 192.168.0.3-192.168.0.5
echo "create 4 vms"
aliyun ecs RunInstances --Amount 4 \
--ImageId centos_7_04_64_20G_alibase_201701015.vhd \
--InstanceType ecs.c5.xlarge \
--Action RunInstances \
--InternetChargeType PayByTraffic \
--InternetMaxBandwidthIn 50 \
--InternetMaxBandwidthOut 50 \
--Password Fanux#123 \
--InstanceChargeType PostPaid \
--SpotStrategy SpotAsPriceGo \
--RegionId cn-hongkong \
--SecurityGroupId sg-j6cg7qx8vufo7vopqwiy \
--VSwitchId vsw-j6crutzktn5vdivgeb6tv \
--ZoneId cn-hongkong-b > InstanceId.json
ID0=$(jq -r ".InstanceIdSets.InstanceIdSet[0]" < InstanceId.json)
ID1=$(jq -r ".InstanceIdSets.InstanceIdSet[1]" < InstanceId.json)
ID2=$(jq -r ".InstanceIdSets.InstanceIdSet[2]" < InstanceId.json)
ID3=$(jq -r ".InstanceIdSets.InstanceIdSet[3]" < InstanceId.json)
echo "sleep 40s wait for IP and FIP"
sleep 40 # wait for IP
aliyun ecs DescribeInstanceAttribute --InstanceId $ID0 > info.json
master0=$(jq -r ".VpcAttributes.PrivateIpAddress.IpAddress[0]" < info.json)
master0FIP=$(jq -r ".PublicIpAddress.IpAddress[0]" < info.json)
aliyun ecs DescribeInstanceAttribute --InstanceId $ID1 > info.json
node0=$(jq -r ".VpcAttributes.PrivateIpAddress.IpAddress[0]" < info.json)
aliyun ecs DescribeInstanceAttribute --InstanceId $ID2 > info.json
node1=$(jq -r ".VpcAttributes.PrivateIpAddress.IpAddress[0]" < info.json)
aliyun ecs DescribeInstanceAttribute --InstanceId $ID3 > info.json
node2=$(jq -r ".VpcAttributes.PrivateIpAddress.IpAddress[0]" < info.json)
echo "all nodes IP: $master0 $node0 $node1 $node2"
echo "wait for sshd start"
sleep 100 # wait for sshd
# $2 is sealos clientip
alias remotecmd="./sshcmd --passwd Fanux#123 --host $master0FIP --cmd"
remotecmd "wget https://github.com/fanux/sealos/releases/download/$3/sealos && chmod +x sealos && mv sealos /usr/bin"
version=$1
pkgurl=$2
echo "./sshcmd sealos command"
remotecmd "sealos init --master $master0 --passwd Fanux#123 --version v$version --pkg-url $pkgurl --podcidr 10.63.0.0/10 \
--svccidr 11.96.0.0/12 --network calico"
remotecmd "cat /root/.sealos/config.yaml"
echo "wait for everything ok"
sleep 40
remotecmd "kubectl get node && kubectl get pod --all-namespaces -o wide"
remotecmd "sealos join --nodes $node0-$node2"
echo "wait for join nodes"
sleep 40
remotecmd "kubectl get node && kubectl get pod --all-namespaces -o wide"
echo "release instance"
sleep 20
aliyun ecs DeleteInstances --InstanceId.1 $ID0 --RegionId cn-hongkong --Force true
aliyun ecs DeleteInstances --InstanceId.1 $ID1 --RegionId cn-hongkong --Force true
aliyun ecs DeleteInstances --InstanceId.1 $ID2 --RegionId cn-hongkong --Force true
aliyun ecs DeleteInstances --InstanceId.1 $ID3 --RegionId cn-hongkong --Force true