# # Author: Hari Sekhon # Date: 2020-08-14 13:16:04 +0100 (Fri, 14 Aug 2020) # (forked from private repo from 2013) # Original Date: 2013-03-18 16:38:04 +0000 (Mon, 18 Mar 2013) # # vim:ts=4:sts=4:sw=4:et:filetype=ruby # # https://github.com/HariSekhon/DevOps-Bash-tools # # License: see accompanying Hari Sekhon LICENSE file # # If you"re using my code you"re welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish # # https://www.linkedin.com/in/HariSekhon # # https://www.vagrantup.com/docs/vagrantfile Vagrant.configure("2") do |config| # https://www.vagrantup.com/docs/boxes # # to get Hashicorp"s Ubuntu 18.04 base box: # # vagrant init hashicorp/bionic64 # # or try one of the Bento boxes: # # https://app.vagrantup.com/bento # #config.vm.box = "hashicorp/bionic64" config.vm.box = "bento/ubuntu-18.04" # root login doesn't work on hashicorp/bionic64 or bento/ubuntu-18.04 box with pw 'vagrant' #config.ssh.username = "root" #config.ssh.password = "vagrant" config.ssh.insert_key = true #config.ssh.private_key_path = "~/.ssh/id_rsa" # host_path guest_path config.vm.synced_folder "~/github", "/github" config.vm.synced_folder "../../", "/bash" config.ssh.forward_agent = false config.ssh.forward_x11 = false config.vm.usable_port_range = 2250..2299 #config.vm.boot_mode = "gui" config.vm.provider "virtualbox" do |vb| vb.gui = false #vb.name = "default-vagrant-hostname" # overridden per VM vb.customize [ "modifyvm", :id, "--name", "#{vb.name}", "--natdnsproxy1", "on", "--usb", "off", "--audio", "none" ] # using the host's DNS is simple but less portable as it requires an extra step of adding the nodes to the host's /etc/hosts file, which is an easy step to miss, so just inject the hosts files in each VM instead #"--natdnshostresolver1", "on", # evaluates too early and gets 'default-vagrant-hostname' #config.vm.hostname = "#{vb.name}" end # generic provision for each VM config.vm.provision :shell, :path => "../provision.sh" # Colocating Etcd cluster on masters to save RAM - uncomment these if you have RAM to burn and want them on separate hosts # ================================== # config.vm.define "etcd1" do |config| # config.vm.network "private_network", ip: "172.16.0.21" # config.vm.provider "virtualbox" do |vb| # # can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname' # vb.name = "etcd1" # vb.cpus = 1 # vb.memory = 1024 # vb.customize [ # "modifyvm", :id, "--name", "#{vb.name}" # ] # # sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1) # config.vm.hostname = "#{vb.name}" # end # end # # config.vm.define "etcd2" do |config| # config.vm.network "private_network", ip: "172.16.0.22" # config.vm.provider "virtualbox" do |vb| # # can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname' # vb.name = "etcd2" # vb.cpus = 1 # vb.memory = 1024 # vb.customize [ # "modifyvm", :id, "--name", "#{vb.name}" # ] # # sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1) # config.vm.hostname = "#{vb.name}" # end # end # # config.vm.define "etcd3" do |config| # config.vm.network "private_network", ip: "172.16.0.23" # config.vm.provider "virtualbox" do |vb| # # can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname' # vb.name = "etcd3" # vb.cpus = 1 # vb.memory = 1024 # vb.customize [ # "modifyvm", :id, "--name", "#{vb.name}" # ] # # sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1) # config.vm.hostname = "#{vb.name}" # end # end # ================================== config.vm.define "master1" do |config| config.vm.network "private_network", ip: "172.16.0.11" config.vm.provider "virtualbox" do |vb| # can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname' vb.name = "master1" vb.cpus = 2 vb.memory = 4096 vb.customize [ "modifyvm", :id, "--name", "#{vb.name}" #"--cpus", 3, #"--memory", 7168 ] # sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1) config.vm.hostname = "#{vb.name}" end config.vm.provision :shell, :path => "provision-kube-master.sh" end config.vm.define "master2" do |config| config.vm.network "private_network", ip: "172.16.0.12" config.vm.provider "virtualbox" do |vb| # can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname' vb.name = "master2" vb.cpus = 2 vb.memory = 4096 vb.customize [ "modifyvm", :id, "--name", "#{vb.name}" ] # sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1) config.vm.hostname = "#{vb.name}" end #config.vm.provision :shell, :path => "provision-kube-master.sh" end config.vm.define "master3" do |config| config.vm.network "private_network", ip: "172.16.0.13" config.vm.provider "virtualbox" do |vb| # can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname' vb.name = "master3" vb.cpus = 1 # Only Etcd on this one so less RAM needed vb.memory = 1024 vb.customize [ "modifyvm", :id, "--name", "#{vb.name}" ] # sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1) config.vm.hostname = "#{vb.name}" end end # ================================== config.vm.define "worker1" do |config| config.vm.network "private_network", ip: "172.16.0.14" config.vm.provider "virtualbox" do |vb| vb.name = "worker1" vb.memory = 2048 vb.cpus = 1 vb.customize [ "modifyvm", :id, "--name", "#{vb.name}" ] config.vm.hostname = "#{vb.name}" end config.vm.provision :shell, :path => "provision-kube-worker.sh" end # Enable if you have lots of ram and want more workers config.vm.define "worker2" do |config| config.vm.network "private_network", ip: "172.16.0.15" config.vm.provider "virtualbox" do |vb| vb.name = "worker2" vb.memory = 2048 vb.cpus = 1 vb.customize [ "modifyvm", :id, "--name", "#{vb.name}" ] config.vm.hostname = "#{vb.name}" end config.vm.provision :shell, :path => "provision-kube-worker.sh" end # config.vm.define "worker3" do |config| # config.vm.network "private_network", ip: "172.16.0.16" # config.vm.provider "virtualbox" do |vb| # vb.name = "worker3" # vb.memory = 2048 # vb.cpus = 1 # vb.customize [ # "modifyvm", :id, "--name", "#{vb.name}" # ] # config.vm.hostname = "#{vb.name}" # end # config.vm.provision :shell, :path => "provision-kube-worker.sh" # end end