-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Vagrantfile
74 lines (60 loc) · 2.56 KB
/
Vagrantfile
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
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version ">= 1.8.3"
num_nodes = (ENV['NNODES'] || 1).to_i
cilium_version = (ENV['CILIUM_VERSION'] || "v1.0.0-rc2")
cilium_opts = (ENV['CILIUM_OPTS'] || "--kvstore consul --kvstore-opt consul.address 192.168.33.11:8500 -t vxlan")
cilium_tag = (ENV['CILIUM_TAG'] || "v1.0.0-rc2")
# This runs only once when vagrant box is provisioned for the first time
$bootstrap = <<SCRIPT
# install docker-compose
curl -sS -L "https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# install cilium client
curl -sS -L "https://github.com/cilium/cilium/releases/download/#{cilium_version}/cilium-x86_64" -o /usr/local/bin/cilium
chmod +x /usr/local/bin/cilium
# Store specified tag and options for docker-compose so we can rerun easily
cat > /home/vagrant/cilium/examples/getting-started/.env <<EOF
CILIUM_TAG=#{cilium_tag}
CILIUM_OPTS=#{cilium_opts}
EOF
# cd into getting-started directory by default
echo 'cd ~/cilium/examples/getting-started' >> /home/vagrant/.bashrc
SCRIPT
# This is run every time vagrant box is booted
$run = <<SCRIPT
sudo mount bpffs /sys/fs/bpf -t bpf
cd ~/cilium/examples/getting-started
sudo -E docker-compose up -d --remove-orphans
SCRIPT
Vagrant.configure(2) do |config|
config.vm.box = "bento/ubuntu-17.04"
# http://foo-o-rama.com/vagrant--stdin-is-not-a-tty--fix.html
config.vm.provision "fix-no-tty", type: "shell" do |s|
s.privileged = false
s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile"
end
config.vm.synced_folder "../..", "/home/vagrant/cilium", disabled: false
config.vm.provider "virtualbox" do |vb|
# Do not inherit DNS server from host, use proxy
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
# install docker runtime
config.vm.provision :docker, images: [
"consul:0.8.3",
"cilium/cilium:#{cilium_tag}"
]
config.vm.provision "bootstrap", type: "shell", inline: $bootstrap
config.vm.provision "run", type: "shell", run: "always",
env: {"CILIUM_TAG" => cilium_tag, "CILIUM_OPTS" => cilium_opts},
privileged: false, inline: $run
(1..num_nodes).each do |n|
node_vm_name = "cilium-#{n}"
config.vm.define node_vm_name do |node|
node.vm.hostname = node_vm_name
node_ip = "192.168.33.1#{n}"
node.vm.network "private_network", ip: "#{node_ip}"
end
end
end