Skip to content

Commit

Permalink
Merge pull request #26 from Roblox/vagrant
Browse files Browse the repository at this point in the history
Vagrant setup.
  • Loading branch information
shishir-a412ed authored Jul 16, 2020
2 parents 41729b9 + 8834f94 commit 6048144
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 242 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vagrant/
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Docker daemon is not required on the host system.
- [Nomad](https://www.nomadproject.io/downloads.html) >=v0.11
- [Go](https://golang.org/doc/install) >=v1.11
- [Containerd](https://containerd.io/downloads/) >=1.3
- [Vagrant](https://www.vagrantup.com/downloads.html) >=v2.2
- [VirtualBox](https://www.virtualbox.org/) v6.0 (or any version vagrant is compatible with)

## Building nomad-driver-containerd

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

```
./setup.sh
$ vagrant up
```
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.
or `vagrant provision` if the vagrant VM is already running.

**NOTE** `setup.sh` overrides your existing `containerd` to `containerd-1.3.4`. This is needed for `io.containerd.runc.v2` runtime.<br/>
Your original containerd systemd unit file will be backed up at `/lib/systemd/system/containerd.service.bkp` in case you wanna revert later.

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:
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:
```
$ nomad node status (Note down the <node_id>)
$ nomad node status <node_id> | grep containerd-driver
```

**NOTE:** [`setup.sh`](vagrant/setup.sh) is part of the vagrant setup and should not be executed directly.

## Run Example jobs.

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

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

## Supported options
Expand Down Expand Up @@ -120,6 +120,11 @@ make clean
```
This will delete your binary: `containerd-driver`

```
vagrant destroy
```
This will destroy your vagrant VM.

## Currently supported environments
Ubuntu (>= 16.04)

Expand Down
54 changes: 54 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Specify minimum Vagrant version and Vagrant API version
Vagrant.require_version ">= 1.6.0"
VAGRANTFILE_API_VERSION = "2"

# Create box
Vagrant.configure("2") do |config|
config.vm.define "containerd-linux"
config.vm.box = "hashicorp/bionic64"
config.vm.synced_folder ".", "/home/vagrant/go/src/nomad-driver-containerd"
config.ssh.extra_args = ["-t", "cd /home/vagrant/go/src/nomad-driver-containerd; bash --login"]
config.vm.network "forwarded_port", guest: 4646, host: 4646, host_ip: "127.0.0.1"
config.vm.provider "virtualbox" do |vb|
vb.name = "containerd-linux"
vb.cpus = 2
vb.memory = 2048
end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y unzip gcc runc
echo "export GOPATH=/home/vagrant/go" >> /home/vagrant/.bashrc
echo "export PATH=$PATH:/usr/local/go/bin" >> /home/vagrant/.bashrc
source /home/vagrant/.bashrc
# Install golang-1.14.3
if [ ! -f "/usr/local/go/bin/go" ]; then
curl -s -L -o go1.14.3.linux-amd64.tar.gz https://dl.google.com/go/go1.14.3.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.14.3.linux-amd64.tar.gz
sudo chmod +x /usr/local/go
rm -f go1.14.3.linux-amd64.tar.gz
fi
# Install nomad-0.11.3
if [ ! -f "/usr/bin/nomad" ]; then
wget --quiet https://releases.hashicorp.com/nomad/0.11.3/nomad_0.11.3_linux_amd64.zip
unzip nomad_0.11.3_linux_amd64.zip -d /usr/bin
chmod +x /usr/bin/nomad
rm -f nomad_0.11.3_linux_amd64.zip
fi
# Install containerd-1.3.4
if [ ! -f "/usr/local/bin/containerd" ]; then
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
tar -C /usr/local -xzf containerd-1.3.4.linux-amd64.tar.gz
rm -f containerd-1.3.4.linux-amd64.tar.gz
fi
# Create source directory for privileged.nomad example job.
mkdir -p /tmp/s1
# Run setup
cd /home/vagrant/go/src/nomad-driver-containerd/vagrant
./setup.sh
SHELL
end
235 changes: 0 additions & 235 deletions setup.sh

This file was deleted.

Loading

0 comments on commit 6048144

Please sign in to comment.