-
Notifications
You must be signed in to change notification settings - Fork 3
/
cluster
executable file
·97 lines (84 loc) · 2.96 KB
/
cluster
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
#!/bin/sh
function main {
case "$1" in
"certs") certs;;
"start") start;;
"stop") stop;;
"create-nodes") createNodes;;
"start-registries") startRegistries;;
esac
}
function certs {
terraform apply
}
function stop {
systemctl stop \
matchbox \
matchbox-dnsmasq
rkt gc --grace-period=0s
systemctl reset-failed
}
function start {
systemd-run --unit=matchbox -p WorkingDirectory=$(pwd) \
rkt run \
--insecure-options=image,ondisk \
--stage1-path=/usr/lib/rkt/stage1-images/stage1-coreos.aci \
--net=metal0:IP=10.1.1.2 \
--dns=10.1.1.3 \
quay.io/coreos/matchbox:latest \
--mount volume=assets,target=/var/lib/matchbox/assets \
--volume assets,kind=host,source=$PWD/assets \
--mount volume=etc-matchbox,target=/etc/matchbox \
--volume etc-matchbox,kind=host,source=$PWD/certs \
-- \
-address=0.0.0.0:8080 \
-rpc-address=0.0.0.0:8081 \
-log-level=debug
systemd-run --unit=matchbox-dnsmasq -p WorkingDirectory=$(pwd) \
rkt run \
--insecure-options=image,ondisk \
--stage1-path=/usr/lib/rkt/stage1-images/stage1-coreos.aci \
--net=metal0:IP=10.1.1.3 \
--dns=10.1.1.3 \
quay.io/coreos/dnsmasq \
--caps-retain=CAP_NET_ADMIN,CAP_NET_BIND_SERVICE \
--mount volume=config,target=/etc/dnsmasq.conf \
--volume config,kind=host,source=$PWD/dnsmasq/metal0.conf \
--mount volume=resolv,target=/etc/resolv.dnsmasq \
--volume resolv,kind=host,source=$PWD/dnsmasq/resolv.dnsmasq \
--mount volume=hosts,target=/etc/hosts.dnsmasq \
--volume hosts,kind=host,source=$PWD/dnsmasq/hosts.dnsmasq
local i=0
while true; do
(( i++ )) && (( i == 100 )) && echo "giving up" && exit 1
echo "looking up ..."
nslookup registry.k8s 10.1.1.3
if [ "$?" -eq 0 ]; then
break
fi
done
}
function startRegistries {
startNginx
startRegistry quay 10.1.1.6
startRegistry gcr 10.1.1.7
}
function startNginx {
systemd-run --unit=registry-proxy \
-p WorkingDirectory=$(pwd) \
rkt run \
--insecure-options=image,ondisk \
--stage1-path=/usr/lib/rkt/stage1-images/stage1-coreos.aci \
--net=metal0:IP=10.1.1.5 \
--dns=10.1.1.3 \
docker://nginx:1.13.0 \
--mount volume=registry,target=/etc/nginx/nginx.conf \
--volume registry,kind=host,source=$PWD/registry/nginx.conf
}
COMMON_VIRT_OPTS="--memory=4096 --vcpus=1 --pxe --disk pool=default,size=12 --os-type=linux --os-variant=generic --noautoconsole"
function createNodes {
virt-install --name master1 --network=bridge:metal0,mac=0a:0b:0c:0d:0e:10 $COMMON_VIRT_OPTS --boot=hd,network
virt-install --name worker1 --network=bridge:metal0,mac=0a:0b:0c:0d:0e:50 $COMMON_VIRT_OPTS --boot=hd,network
virt-install --name worker2 --network=bridge:metal0,mac=0a:0b:0c:0d:0e:51 $COMMON_VIRT_OPTS --boot=hd,network
}
main $@