-
Notifications
You must be signed in to change notification settings - Fork 2
/
Vagrantfile
101 lines (96 loc) · 3.51 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
99
100
101
Vagrant.configure(2) do |config|
config.vm.synced_folder './shared', '/home/vagrant/shared',
create: true, owner: 'vagrant', group: 'vagrant'
config.vm.synced_folder './ansible', '/home/vagrant/ansible',
create: true, owner: 'vagrant', group: 'vagrant'
# BGP Router
config.vm.define 'rt-01' do |node|
node.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--ostype', 'Debian_64']
vb.cpus = 1
vb.memory = 512
vb.gui = false
end
node.vm.hostname = 'rt-01'
node.vm.box = 'ubuntu/bionic64'
# enp0s8
node.vm.network 'private_network',
ip: '172.17.0.1', netmask: '255.255.255.0', auto_config: true,
virtualbox__intnet: 'k8s-cluster'
# enp0s9
node.vm.network 'private_network',
ip: '172.17.1.1', netmask: '255.255.255.0', auto_config: true,
virtualbox__intnet: 'client'
node.vm.provision :ansible_local do |ansible|
ansible.compatibility_mode = '2.0'
ansible.playbook = '/home/vagrant/ansible/all.yml'
ansible.inventory_path = '/home/vagrant/ansible/inventories/router'
ansible.limit = 'routers'
end
end
# client-01
config.vm.define 'client-01' do |node|
node.vm.provider 'virtualbox' do |vb|
vb.cpus = 1
vb.memory = 512
vb.gui = false
end
node.vm.hostname = 'client-01'
node.vm.box = 'ubuntu/bionic64'
# port forward
node.vm.network 'forwarded_port', guest: 80, host: 10080
node.vm.network 'forwarded_port', guest: 6443, host: 6443
# enp0s8
node.vm.network 'private_network',
ip: '172.17.1.10', netmask: '255.255.255.0', auto_config: true,
virtualbox__intnet: 'client'
node.vm.provision :ansible_local do |ansible|
ansible.compatibility_mode = '2.0'
ansible.playbook = '/home/vagrant/ansible/all.yml'
ansible.inventory_path = '/home/vagrant/ansible/inventories/clients'
ansible.limit = 'clients'
end
end
# k8s-master-01
config.vm.define 'k8s-master-01' do |node|
node.vm.provider 'virtualbox' do |vb|
vb.cpus = 2
vb.memory = 2048
vb.gui = false
end
node.vm.hostname = 'k8s-master-01'
node.vm.box = 'ubuntu/bionic64'
# enp0s8
node.vm.network 'private_network',
ip: '172.17.0.10', netmask: '255.255.255.0', auto_config: true,
virtualbox__intnet: 'k8s-cluster'
node.vm.provision :ansible_local do |ansible|
ansible.compatibility_mode = '2.0'
ansible.playbook = '/home/vagrant/ansible/all.yml'
ansible.inventory_path = '/home/vagrant/ansible/inventories/masters'
ansible.limit = 'masters'
end
end
# k8s-nodes
(1..3).each do |i|
hostname = 'k8s-node-%s' % (i.to_s.rjust(2,'0'))
config.vm.define hostname do |node|
node.vm.provider 'virtualbox' do |vb|
vb.cpus = 2
vb.memory = 1024
vb.gui = false
end
node.vm.hostname = hostname
node.vm.box = 'ubuntu/bionic64'
node.vm.network 'private_network',
ip: '172.17.0.%s' % ( i + 20 ), netmask: '255.255.255.0', auto_config: true,
virtualbox__intnet: 'k8s-cluster'
node.vm.provision :ansible_local do |ansible|
ansible.compatibility_mode = '2.0'
ansible.playbook = '/home/vagrant/ansible/all.yml'
ansible.inventory_path = '/home/vagrant/ansible/inventories/nodes'
ansible.limit = 'nodes'
end
end
end
end