-
-
Save kocogluali/2d60ee6b387a9a248bbc3f2b8625271a to your computer and use it in GitHub Desktop.
Vagrantfile used in Istanbul Coders - Kubernetes Introduction Meetup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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