Skip to content

Instantly share code, notes, and snippets.

@alphajc
Created July 18, 2019 01:15
Show Gist options
  • Save alphajc/b79e7f2d7e64d940b5ccbb8b855a3620 to your computer and use it in GitHub Desktop.
Save alphajc/b79e7f2d7e64d940b5ccbb8b855a3620 to your computer and use it in GitHub Desktop.
Vagrant 启动集群
Vagrant.configure("2") do |config|
(1..3).each do |i|
config.vm.define "calico#{i}" do |node|
# 设置虚拟机的Box
node.vm.box = "ubuntu/bionic"
# 设置虚拟机的主机名
node.vm.hostname="calico#{i}"
# 设置虚拟机的IP
node.vm.network "private_network", ip: "172.17.8.#{i}"
# 设置主机与虚拟机的共享目录
node.vm.synced_folder "~/Documents/share", "/home/vagrant/share"
# VirtaulBox相关配置
node.vm.provider "virtualbox" do |v|
# 设置虚拟机的名称
v.name = "calico#{i}"
# 设置虚拟机的内存大小
v.memory = 1024
# 设置虚拟机的CPU个数
v.cpus = 1
end
# 使用shell脚本进行软件安装和配置
node.vm.provision "shell", inline: <<-SHELL
# 安装docker
snap install docker
echo 'export PATH=$PATH:/snap/bin' >> /etc/profile
SHELL
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment