This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Vagrantfile
70 lines (55 loc) · 2.17 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
SOLUTION = "k8s" # default/devops/k8s
BOXES ={
"ubuntu" => "ubuntu/focal64",
"centos" => "centos/7"
}
DISTRO = "ubuntu" # centos/ubuntu
MIRROR = "tencent" # <empty>/aliyun/tencent
ADMIN_IP = "192.168.56.10"
NODES = 2
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "admin", primary: true do |admin|
admin.vm.box_check_update = true
admin.vm.box = "#{BOXES[DISTRO]}"
admin.vm.provider "virtualbox" do |v|
v.name = "admin"
v.memory = 4096
v.cpus = 2
end
admin.vm.synced_folder ".", "/vagrant", type: "rsync"
#Private_network Settings
admin.vm.network "private_network", ip: "#{ADMIN_IP}"
admin.vm.hostname = "admin"
#SSH
admin.ssh.forward_agent = true
admin.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
# Provision admin Node
admin.vm.provision "shell", path: "./init/init.sh", args: "#{MIRROR} #{DOCKER_USERNAME} #{DOCKER_PASSWORD} #{DOCKER_REGISTRY}", privileged: false, reset: true
admin.vm.provision "shell", path: "./solution/#{SOLUTION}/admin.sh", args: "#{ADMIN_IP}", privileged: false, reset: true
end
(1..NODES).each do |i|
config.vm.define "node-#{i}", autostart:true do |node|
node.vm.box_check_update = true
node.vm.box = "#{BOXES[DISTRO]}"
node.vm.provider "virtualbox" do |v|
v.name = "node-#{i}"
v.memory = 2048
v.cpus = 2
end
node.vm.synced_folder ".", "/vagrant", type: "rsync"
# Private_network Settings
node.vm.network "private_network", ip: "192.168.56.#{i+1}"
node.vm.hostname = "node-#{i}"
# SSH
node.ssh.forward_agent = true
node.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
# Provision node Node
node.vm.provision "shell", path: "./init/init.sh", args: "#{MIRROR} #{DOCKER_USERNAME} #{DOCKER_PASSWORD} #{DOCKER_REGISTRY}", privileged: false, reset: true
node.vm.provision "shell", path: "./solution/#{SOLUTION}/node.sh", args: "#{ADMIN_IP}", privileged: false, reset: true
end
end
end