From 1b4ef4b377651f74399c0427b3d3b92d84e62093 Mon Sep 17 00:00:00 2001 From: zhanglikun Date: Thu, 18 May 2023 14:32:16 +0800 Subject: [PATCH] add vagrantfile --- 0-config.sh | 3 ++- Vagrantfile | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 Vagrantfile diff --git a/0-config.sh b/0-config.sh index e096411..4709117 100644 --- a/0-config.sh +++ b/0-config.sh @@ -10,4 +10,5 @@ sed -e "s/10.0.0.11/${master1}/g" \ -e "s/10.0.0.13/${master3}/g" \ -e "s/10.0.0.3/${vip}/g" \ -i keepalived/*.conf \ - -i 2-create_k8s.sh \ No newline at end of file + -i 2-create_k8s.sh \ + -i Vagrantfile \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..19046e7 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,34 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +servers = { + :master1 => '10.0.0.11', + :master2 => '10.0.0.12', + :master3 => '10.0.0.13' +} + +Vagrant.configure("2") do |config| + config.vm.box = "centos/7" + config.vm.box_check_update = false + + # 自动插入hosts + # vagrant plugin install vagrant-hostmanager + config.hostmanager.enabled = true + config.hostmanager.manage_host = true + config.hostmanager.manage_guest = true + config.hostmanager.ignore_private_ip = false + config.hostmanager.include_offline = true + + + servers.each do |server_name, server_ip| + config.vm.define server_name do |server_config| + server_config.vm.hostname = "#{server_name.to_s}" + server_config.vm.network :private_network, ip: server_ip + server_config.vm.provider "virtualbox" do |vb| + vb.name = server_name.to_s + vb.memory = "2048" + vb.cpus = 4 + end + end + end +end \ No newline at end of file