Last active
June 16, 2018 06:10
-
-
Save joec4i/a4900ff3d68fe62934cc74337be99144 to your computer and use it in GitHub Desktop.
A vagrant vm cluster for kubernetes
This file contains 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 : | |
hosts = { | |
"master" => { | |
:ip => "192.168.66.10", | |
:cpus => 1, | |
:memory => 1024 | |
}, | |
"node1" => { | |
:ip => "192.168.66.11", | |
:cpus => 3, | |
:memory => 4096 | |
} | |
} | |
Vagrant.configure("2") do |config| | |
# always use Vagrants insecure key | |
config.ssh.insert_key = false | |
# forward ssh agent to easily ssh into the different machines | |
config.ssh.forward_agent = true | |
check_guest_additions = false | |
functional_vboxsf = false | |
config.vm.box = "bento/ubuntu-16.04" | |
hosts.each do |name, m| | |
config.vm.define name do |machine| | |
machine.vm.hostname = name | |
machine.vm.network :private_network, ip: m[:ip] | |
machine.vm.provider "virtualbox" do |v| | |
v.name = name | |
v.cpus = m[:cpus] | |
v.memory = m[:memory] | |
end | |
end | |
end | |
config.vm.provision "shell", inline: <<-SHELL | |
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/k8s.list | |
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
apt-get update | |
apt-get upgrade -y | |
apt-get install -y docker.io kubeadm kubelet | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment