Skip to content

Instantly share code, notes, and snippets.

@TheYkk
Forked from gokhansengun/Vagrantfile
Created December 10, 2018 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheYkk/cbe07d98e536fbe23a952d4f72d99f70 to your computer and use it in GitHub Desktop.
Save TheYkk/cbe07d98e536fbe23a952d4f72d99f70 to your computer and use it in GitHub Desktop.
Vagrantfile used in Istanbul Coders - Kubernetes Introduction Meetup
# -*- mode: ruby -*-
# vi: set ft=ruby :
K8S_DEV_BOX_NAME = "gsengun/k8s-dev-box"
K8S_DEV_BOX_VERSION = "17.12.27"
MASTER_NODE_IP_START="172.27.44.20"
WORKER_NODE_IP_START="172.27.44.10"
JOIN_TOKEN="abcdef.1234567890123456"
Vagrant.configure(2) do |config|
(0..0).each do |i|
config.vm.define "m" do |node|
node.vm.box = K8S_DEV_BOX_NAME
node.vm.box_version = K8S_DEV_BOX_VERSION
node.vm.hostname = "m"
node.vm.network "private_network", ip: "#{MASTER_NODE_IP_START}#{i}"
# hostname -i must return a routable address on second (non-NATed) network interface
# see 5) in http://kubernetes.io/docs/getting-started-guides/kubeadm/#limitations
node.vm.provision "shell", inline: "sed 's/127.0.0.1.*m/#{MASTER_NODE_IP_START}#{i} m/' -i /etc/hosts"
node.vm.provision "shell", inline: "echo 'cd /vagrant' >> ~/.bashrc && exit", privileged: false
# Setup resources
node.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = 1
end
end
end
(1..2).each do |i|
config.vm.define "n#{i}" do |node|
node.vm.box = K8S_DEV_BOX_NAME
node.vm.box_version = K8S_DEV_BOX_VERSION
node.vm.hostname = "n#{i}"
node.vm.network "private_network", ip: "#{WORKER_NODE_IP_START}#{i-1}"
# hostname -i must return a routable address on second (non-NATed) network interface
# see 5) in http://kubernetes.io/docs/getting-started-guides/kubeadm/#limitations
node.vm.provision "shell", inline: "sed 's/127.0.0.1.*n#{i}/#{WORKER_NODE_IP_START}#{i} n#{i}/' -i /etc/hosts"
node.vm.provision "shell", inline: "echo 'cd /vagrant' >> ~/.bashrc && exit", privileged: false
node.vm.provision "shell", inline: "route add 10.96.0.1 gw #{MASTER_NODE_IP_START}0 && exit", privileged: true, run: "always"
# Setup resources
node.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = 1
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment