Skip to content

Commit 6048144

Browse files
Merge pull request #26 from Roblox/vagrant
Vagrant setup.
2 parents 41729b9 + 8834f94 commit 6048144

File tree

5 files changed

+165
-242
lines changed

5 files changed

+165
-242
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vagrant/

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Docker daemon is not required on the host system.
2323
- [Nomad](https://www.nomadproject.io/downloads.html) >=v0.11
2424
- [Go](https://golang.org/doc/install) >=v1.11
2525
- [Containerd](https://containerd.io/downloads/) >=1.3
26+
- [Vagrant](https://www.vagrantup.com/downloads.html) >=v2.2
27+
- [VirtualBox](https://www.virtualbox.org/) v6.0 (or any version vagrant is compatible with)
2628

2729
## Building nomad-driver-containerd
2830

@@ -37,19 +39,18 @@ $ make build (This will build your containerd-driver binary)
3739
## Wanna try it out!?
3840

3941
```
40-
./setup.sh
42+
$ vagrant up
4143
```
42-
The setup script will setup `containerd 1.3.4` and `nomad server+nomad-driver-containerd` (nomad server/client should already be installed on your system, and `setup.sh` only builds the driver) on your system, so you can try out [`example`](https://github.com/Roblox/nomad-driver-containerd/tree/master/example) jobs.
44+
or `vagrant provision` if the vagrant VM is already running.
4345

44-
**NOTE** `setup.sh` overrides your existing `containerd` to `containerd-1.3.4`. This is needed for `io.containerd.runc.v2` runtime.<br/>
45-
Your original containerd systemd unit file will be backed up at `/lib/systemd/system/containerd.service.bkp` in case you wanna revert later.
46-
47-
Once `setup.sh` is complete and the nomad server is up and running, you can check the registered task drivers (which will also show `containerd-driver`) using:
46+
Once setup (`vagrant up` OR `vagrant provision`) is complete and the nomad server is up and running, you can check the registered task drivers (which will also show `containerd-driver`) using:
4847
```
4948
$ nomad node status (Note down the <node_id>)
5049
$ nomad node status <node_id> | grep containerd-driver
5150
```
5251

52+
**NOTE:** [`setup.sh`](vagrant/setup.sh) is part of the vagrant setup and should not be executed directly.
53+
5354
## Run Example jobs.
5455

5556
There are few example jobs in the [`example`](https://github.com/Roblox/nomad-driver-containerd/tree/master/example) directory.
@@ -59,7 +60,6 @@ $ nomad job run <job_name.nomad>
5960
```
6061
will launch the job.<br/>
6162

62-
**NOTE:** You need to run `setup.sh` before trying out the example jobs.<br/>
6363
More detailed instructions are in the [`example README.md`](https://github.com/Roblox/nomad-driver-containerd/tree/master/example)
6464

6565
## Supported options
@@ -120,6 +120,11 @@ make clean
120120
```
121121
This will delete your binary: `containerd-driver`
122122

123+
```
124+
vagrant destroy
125+
```
126+
This will destroy your vagrant VM.
127+
123128
## Currently supported environments
124129
Ubuntu (>= 16.04)
125130

Vagrantfile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Specify minimum Vagrant version and Vagrant API version
2+
Vagrant.require_version ">= 1.6.0"
3+
VAGRANTFILE_API_VERSION = "2"
4+
5+
# Create box
6+
Vagrant.configure("2") do |config|
7+
config.vm.define "containerd-linux"
8+
config.vm.box = "hashicorp/bionic64"
9+
config.vm.synced_folder ".", "/home/vagrant/go/src/nomad-driver-containerd"
10+
config.ssh.extra_args = ["-t", "cd /home/vagrant/go/src/nomad-driver-containerd; bash --login"]
11+
config.vm.network "forwarded_port", guest: 4646, host: 4646, host_ip: "127.0.0.1"
12+
config.vm.provider "virtualbox" do |vb|
13+
vb.name = "containerd-linux"
14+
vb.cpus = 2
15+
vb.memory = 2048
16+
end
17+
config.vm.provision "shell", inline: <<-SHELL
18+
apt-get update
19+
apt-get install -y unzip gcc runc
20+
echo "export GOPATH=/home/vagrant/go" >> /home/vagrant/.bashrc
21+
echo "export PATH=$PATH:/usr/local/go/bin" >> /home/vagrant/.bashrc
22+
source /home/vagrant/.bashrc
23+
24+
# Install golang-1.14.3
25+
if [ ! -f "/usr/local/go/bin/go" ]; then
26+
curl -s -L -o go1.14.3.linux-amd64.tar.gz https://dl.google.com/go/go1.14.3.linux-amd64.tar.gz
27+
sudo tar -C /usr/local -xzf go1.14.3.linux-amd64.tar.gz
28+
sudo chmod +x /usr/local/go
29+
rm -f go1.14.3.linux-amd64.tar.gz
30+
fi
31+
32+
# Install nomad-0.11.3
33+
if [ ! -f "/usr/bin/nomad" ]; then
34+
wget --quiet https://releases.hashicorp.com/nomad/0.11.3/nomad_0.11.3_linux_amd64.zip
35+
unzip nomad_0.11.3_linux_amd64.zip -d /usr/bin
36+
chmod +x /usr/bin/nomad
37+
rm -f nomad_0.11.3_linux_amd64.zip
38+
fi
39+
40+
# Install containerd-1.3.4
41+
if [ ! -f "/usr/local/bin/containerd" ]; then
42+
curl -L --silent -o containerd-1.3.4.linux-amd64.tar.gz https://github.com/containerd/containerd/releases/download/v1.3.4/containerd-1.3.4.linux-amd64.tar.gz
43+
tar -C /usr/local -xzf containerd-1.3.4.linux-amd64.tar.gz
44+
rm -f containerd-1.3.4.linux-amd64.tar.gz
45+
fi
46+
47+
# Create source directory for privileged.nomad example job.
48+
mkdir -p /tmp/s1
49+
50+
# Run setup
51+
cd /home/vagrant/go/src/nomad-driver-containerd/vagrant
52+
./setup.sh
53+
SHELL
54+
end

setup.sh

Lines changed: 0 additions & 235 deletions
This file was deleted.

0 commit comments

Comments
 (0)