-
Notifications
You must be signed in to change notification settings - Fork 1
/
01-deploy-multinode-k8s.sh
executable file
·53 lines (42 loc) · 1.35 KB
/
01-deploy-multinode-k8s.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
#!/bin/bash
set -xe
declare -A \
NODES=( ["n1"]="172.24.1.10" ["n2"]="172.24.1.11" ["n3"]="172.24.1.12" )
function copy_keys_to_node {
id_key="etc/.vagrant/machines/$1/virtualbox/private_key"
for node in "${!NODES[@]}"; do
key="etc/.vagrant/machines/$node/virtualbox/private_key"
scp -o "LogLevel=FATAL" \
-o "Compression=yes" \
-o "DSAAuthentication=yes" \
-o "IdentitiesOnly=yes" \
-o "StrictHostKeyChecking=no" \
-o "UserKnownHostsFile=/dev/null" \
-i "$id_key" "$key" ubuntu@"${NODES[$1]}":/home/ubuntu/.ssh/"$node"
done
}
function execute_master_cmd {
ssh -o "LogLevel=FATAL" \
-o "Compression=yes" \
-o "DSAAuthentication=yes" \
-o "IdentitiesOnly=yes" \
-o "StrictHostKeyChecking=no" \
-o "UserKnownHostsFile=/dev/null" \
-i "etc/.vagrant/machines/n1/virtualbox/private_key" \
[email protected] "cd /opt/openstack-helm-infra && $*"
}
# Start/provision Vagrant VMs
pushd "$(pwd)"
cd etc
vagrant up
popd
# Copy Vagrant SSH keys to all nodes
for node in "${!NODES[@]}"; do
copy_keys_to_node "$node"
done
# Install GNU Make on n1
execute_master_cmd "sudo apt-get update"
execute_master_cmd "sudo apt-get install make"
# Deploy K8s
execute_master_cmd "make dev-deploy setup-host multinode"
execute_master_cmd "make dev-deploy k8s multinode"