Skip to content

Instantly share code, notes, and snippets.

@praveenkumar
Created December 24, 2019 16:44
Show Gist options
  • Save praveenkumar/4a133564d1d843c0bc53aaac9d2055fe to your computer and use it in GitHub Desktop.
Save praveenkumar/4a133564d1d843c0bc53aaac9d2055fe to your computer and use it in GitHub Desktop.
running k8s hard way using vagrant hard way
# git diff
diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile
index 338ca59..bc6c1cd 100644
--- a/vagrant/Vagrantfile
+++ b/vagrant/Vagrantfile
@@ -23,7 +23,7 @@ Vagrant.configure("2") do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
# config.vm.box = "base"
- config.vm.box = "ubuntu/bionic64"
+ config.vm.box = "generic/ubuntu1804"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
@@ -57,17 +57,17 @@ Vagrant.configure("2") do |config|
(1..NUM_MASTER_NODE).each do |i|
config.vm.define "master-#{i}" do |node|
# Name shown in the GUI
- node.vm.provider "virtualbox" do |vb|
- vb.name = "kubernetes-ha-master-#{i}"
+ node.vm.provider "libvirt" do |vb|
+ vb.random_hostname = "kubernetes-ha-master-#{i}"
vb.memory = 2048
vb.cpus = 2
end
node.vm.hostname = "master-#{i}"
- node.vm.network :private_network, ip: IP_NW + "#{MASTER_IP_START + i}"
+ node.vm.network :private_network, ip: IP_NW + "#{MASTER_IP_START + i}", libvirt__network_name: "k8s"
node.vm.network "forwarded_port", guest: 22, host: "#{2710 + i}"
node.vm.provision "setup-hosts", :type => "shell", :path => "ubuntu/vagrant/setup-hosts.sh" do |s|
- s.args = ["enp0s8"]
+ s.args = ["eth1"]
end
node.vm.provision "setup-dns", type: "shell", :path => "ubuntu/update-dns.sh"
@@ -77,17 +77,17 @@ Vagrant.configure("2") do |config|
# Provision Load Balancer Node
config.vm.define "loadbalancer" do |node|
- node.vm.provider "virtualbox" do |vb|
- vb.name = "kubernetes-ha-lb"
+ node.vm.provider "libvirt" do |vb|
+ vb.random_hostname = "kubernetes-ha-lb"
vb.memory = 512
...skipping...
@@ -77,17 +77,17 @@ Vagrant.configure("2") do |config|
# Provision Load Balancer Node
config.vm.define "loadbalancer" do |node|
- node.vm.provider "virtualbox" do |vb|
- vb.name = "kubernetes-ha-lb"
+ node.vm.provider "libvirt" do |vb|
+ vb.random_hostname = "kubernetes-ha-lb"
vb.memory = 512
vb.cpus = 1
end
node.vm.hostname = "loadbalancer"
- node.vm.network :private_network, ip: IP_NW + "#{LB_IP_START}"
+ node.vm.network :private_network, ip: IP_NW + "#{LB_IP_START}", libvirt__network_name: "k8s"
node.vm.network "forwarded_port", guest: 22, host: 2730
node.vm.provision "setup-hosts", :type => "shell", :path => "ubuntu/vagrant/setup-hosts.sh" do |s|
- s.args = ["enp0s8"]
+ s.args = ["eth1"]
end
node.vm.provision "setup-dns", type: "shell", :path => "ubuntu/update-dns.sh"
@@ -97,17 +97,17 @@ Vagrant.configure("2") do |config|
# Provision Worker Nodes
(1..NUM_WORKER_NODE).each do |i|
config.vm.define "worker-#{i}" do |node|
- node.vm.provider "virtualbox" do |vb|
- vb.name = "kubernetes-ha-worker-#{i}"
+ node.vm.provider "libvirt" do |vb|
+ vb.random_hostname = "kubernetes-ha-worker-#{i}"
vb.memory = 512
vb.cpus = 1
end
node.vm.hostname = "worker-#{i}"
- node.vm.network :private_network, ip: IP_NW + "#{NODE_IP_START + i}"
+ node.vm.network :private_network, ip: IP_NW + "#{NODE_IP_START + i}", libvirt__network_name: "k8s"
node.vm.network "forwarded_port", guest: 22, host: "#{2720 + i}"
node.vm.provision "setup-hosts", :type => "shell", :path => "ubuntu/vagrant/setup-hosts.sh" do |s|
- s.args = ["enp0s8"]
+ s.args = ["eth1"]
end
node.vm.provision "setup-dns", type: "shell", :path => "ubuntu/update-dns.sh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment