-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·51 lines (41 loc) · 1.08 KB
/
start.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
#!/bin/bash
set -ex
sudo apt install conntrack
sudo modprobe br_netfilter
function create_lxc_node {
local node_name=$1
read -r -d '' raw_lxc <<RAW_LXC || true
lxc.apparmor.profile=unconfined
lxc.mount.auto=proc:rw sys:rw cgroup:rw
lxc.cgroup.devices.allow=a
lxc.cgroup.memory.limit_in_bytes=$2
lxc.cap.drop=
lxc.apparmor.allow_incomplete=1
RAW_LXC
lxc launch \
--config security.privileged=true \
--config security.nesting=true \
--config linux.kernel_modules=ip_tables,ip6_tables,netlink_diag,nf_nat,overlay \
--config raw.lxc="${raw_lxc}" \
ubuntu:20.04 ${node_name}
lxc config device add ${node_name} kmsg unix-char source=/dev/kmsg path=/dev/kmsg
set +ex
while :
do
lxc exec ${node_name} -- /bin/bash -c 'curl -s google.com' &> /dev/null
retVal=$?
if [ $retVal -eq 0 ]
then
break
fi
sleep 1
done
set -ex
}
function setup_lb {
create_lxc_node $1 8096M
lxc exec $1 -- /bin/bash -c "apt update && apt install -y nginx"
lxc exec $1 -- /bin/bash -c "echo 'include /etc/nginx/loadbalancer.conf;' >> /etc/nginx/nginx.conf"
./reload_config.sh
}
setup_lb load-balancer