-
Notifications
You must be signed in to change notification settings - Fork 5
/
Vagrantfile
67 lines (52 loc) · 2.05 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
# Require a recent version of vagrant otherwise some have reported errors setting host names on boxes
Vagrant.require_version ">= 1.6.2"
# The number of minions to provision
$num_minion = 2
$swarm_token = "7caa6157dbb4b44053f21d5793ea0158"
# ip configuration
$minion_ip_base = "10.246.2."
$minion_ips = $num_minion.times.collect { |n| $minion_ip_base + "#{n+2}" }
$minion_ips_str = $minion_ips.join(",")
# OS platform to box information
$kube_box = {
"fedora" => {
"name" => "fedora20",
"box_url" => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_fedora-20_chef-provisionerless.box"
}
}
$kube_os="fedora"
# This stuff is cargo-culted from http://www.stefanwrobel.com/how-to-make-vagrant-performance-not-suck
# Give access to half of all cpu cores on the host. We divide by 2 as we assume
# that users are running with hyperthreads.
$vm_cpus = 2
# Give VM 512MB of RAM
$vm_mem = 2048
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
def customize_vm(config)
config.vm.box = $kube_box[$kube_os]["name"]
config.vm.box_url = $kube_box[$kube_os]["box_url"]
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", $vm_mem]
v.customize ["modifyvm", :id, "--cpus", $vm_cpus]
# Use faster paravirtualized networking
v.customize ["modifyvm", :id, "--nictype1", "virtio"]
v.customize ["modifyvm", :id, "--nictype2", "virtio"]
end
end
# Kubernetes minion
$num_minion.times do |n|
config.vm.define "minion-#{n+1}" do |minion|
customize_vm minion
minion_index = n+1
minion_ip = $minion_ips[n]
token = $swarm_token
minion.vm.provision "shell", inline: "/vagrant/provision-minion.sh #{token} #{minion_index} #{minion_ip} #{$num_minion} #{$minion_ips_str}"
minion.vm.network "private_network", ip: "#{minion_ip}"
minion.vm.hostname = "swarm-minion-#{minion_index}"
end
end
end