-
Notifications
You must be signed in to change notification settings - Fork 35
/
setup.sh
executable file
·98 lines (87 loc) · 3.05 KB
/
setup.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
set -euo pipefail
main() {
echo "INFO: Welcome! nomad-driver-containerd setup."
echo "WARN: Some installation steps are time consuming. Please be patient!"
# Save project root directory.
root_dir="/home/vagrant/go/src/github.com/Roblox/nomad-driver-containerd"
pushd $root_dir >/dev/null 2>&1
echo "INFO: Drop systemd unit containerd.service into /lib/systemd/system/containerd.service."
drop_containerd_unit_file
echo "INFO: Reload containerd.service systemd unit."
systemctl daemon-reload
echo "INFO: Starting containerd daemon."
systemctl start containerd
if ! systemctl -q is-active "containerd.service"; then
echo "ERROR: containerd.service didn't come up. journalctl -u containerd.service for more info."
exit 1
fi
echo "INFO: Setup nomad server + nomad-driver-containerd."
export PATH=$PATH:/usr/local/go/bin
echo "INFO: Cleanup any old binaries."
make clean >/dev/null 2>&1
echo "INFO: Build nomad-driver-containerd binary: containerd-driver."
make build >/dev/null 2>&1
echo "INFO: Create plugin-dir for containerd-driver: /tmp/nomad-driver-containerd."
mkdir -p /tmp/nomad-driver-containerd
echo "INFO: Move containerd-driver to /tmp/nomad-driver-containerd."
mv containerd-driver /tmp/nomad-driver-containerd
drop_nomad_unit_file $root_dir
echo "INFO: Reload nomad.service systemd unit."
systemctl daemon-reload
echo "INFO: Starting nomad server + nomad-driver-containerd."
systemctl start nomad
if ! systemctl -q is-active "nomad.service"; then
echo "ERROR: nomad.service didn't come up. journalctl -u nomad.service for more info."
exit 1
fi
popd >/dev/null 2>&1
echo "INFO: Setup finished successfully."
}
drop_nomad_unit_file() {
local nomad=$(which nomad)
# Drop nomad server + nomad-driver-containerd systemd unit file into /lib/systemd/system.
cat << EOF > nomad.service
# /lib/systemd/system/nomad.service
[Unit]
Description=nomad server + nomad-driver-containerd
Documentation=https://nomadproject.io
After=network.target containerd.service
[Service]
ExecStart=$nomad agent -bind=0.0.0.0 -config=$1/example/agent.hcl -plugin-dir=/tmp/nomad-driver-containerd
KillMode=process
Delegate=yes
LimitNOFILE=1048576
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
[Install]
WantedBy=multi-user.target
EOF
mv nomad.service /lib/systemd/system/nomad.service
}
drop_containerd_unit_file() {
# Drop containerd systemd unit file into /lib/systemd/system.
cat << EOF > containerd.service
# /lib/systemd/system/containerd.service
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target
[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd
KillMode=process
Delegate=yes
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
[Install]
WantedBy=multi-user.target
EOF
mv containerd.service /lib/systemd/system/containerd.service
}
main "$@"