forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
98 lines (84 loc) · 3.35 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- mode: ruby -*-
# vi: set ft=ruby :
$use_nfs = ENV['VAGRANT_USE_NFS'] == 'true'
$use_rng = ENV['VAGRANT_USE_RNG'] == 'true'
$cache_docker = ENV['VAGRANT_CACHE_DOCKER'] == 'true'
$cache_rpm = ENV['VAGRANT_CACHE_RPM'] == 'true'
$nodes = (ENV['VAGRANT_NUM_NODES'] || 0).to_i
$config = Hash[*File.read('hack/config.sh').split(/=|\n/)]
$master_ip = $config["master_ip"]
$network_provider = $config["network_provider"]
Vagrant.configure(2) do |config|
config.vm.box = "centos7"
config.vm.box_url = "http://cloud.centos.org/centos/7/vagrant/x86_64/images/CentOS-7-x86_64-Vagrant-1608_01.LibVirt.box"
if Vagrant.has_plugin?("vagrant-cachier") and $cache_rpm then
config.cache.scope = :machine
config.cache.auto_detect = false
config.cache.enable :yum
end
config.vm.provider :libvirt do |domain|
domain.cpus = 2
domain.nested = true # enable nested virtualization
domain.cpu_mode = "host-model"
if $use_rng then
# Will be part of vagrant-libvirt 0.0.36:
# https://github.com/vagrant-libvirt/vagrant-libvirt/pull/654
libvirt.random :model => 'random' # give ovirt-engine some random data for SSO
end
end
if $use_nfs then
config.vm.synced_folder "./", "/vagrant", type: "nfs"
else
config.vm.synced_folder "./", "/vagrant", type: "rsync", rsync__exclude: [ "cluster/vagrant/.kubectl", "cluster/vagrant/.kubeconfig", ".vagrant" ]
end
config.vm.provision "shell", inline: <<-SHELL
#!/bin/bash
set -xe
sed -i -e "s/PasswordAuthentication no/PasswordAuthentication yes/" /etc/ssh/sshd_config
systemctl restart sshd
SHELL
config.vm.define "master" do |master|
master.vm.hostname = "master"
master.vm.network "private_network", ip: "#{$master_ip}"
master.vm.provider :libvirt do |domain|
domain.memory = 3000
if $cache_docker then
domain.storage :file, :size => '10G', :path => 'kubevirt_master_docker.img', :allow_existing => true
end
end
master.vm.provision "shell", inline: <<-SHELL
#!/bin/bash
set -xe
export ADVERTISED_MASTER_IP=#{$master_ip}
export WITH_LOCAL_NFS=true
export NETWORK_PROVIDER=#{$network_provider}
cd /vagrant/cluster/vagrant
bash setup_kubernetes_master.sh
set +x
echo -e "\033[0;32m Deployment was successful!"
echo -e "Cockpit is accessible at https://#{$master_ip}:9090."
echo -e "Credentials for Cockpit are 'root:vagrant'.\033[0m"
SHELL
end
(0..($nodes-1)).each do |suffix|
config.vm.define "node" + suffix.to_s do |node|
node.vm.hostname = "node" + suffix.to_s
node.vm.network "private_network", ip: $master_ip[0..-2] + ($master_ip[-1].to_i + 1 + suffix).to_s
node.vm.provider :libvirt do |domain|
domain.memory = 2048
if $cache_docker then
domain.storage :file, :size => '10G', :path => 'kubevirt_node_docker' + suffix.to_s + '.img', :allow_existing => true
end
end
node.vm.provision "shell", inline: <<-SHELL
#!/bin/bash
set -xe
export ADVERTISED_MASTER_IP=#{$master_ip}
cd /vagrant/cluster/vagrant
bash setup_kubernetes_node.sh
set +x
echo -e "\033[0;32m Deployment was successful!\033[0m"
SHELL
end
end
end