-
Notifications
You must be signed in to change notification settings - Fork 2
/
Vagrantfile
79 lines (64 loc) · 2.33 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Install a kube cluster using kubeadm:
# http://kubernetes.io/docs/getting-started-guides/kubeadm/
### configuration parameters
### Box parameters
box_base = "ubuntu/xenial64"
box_cpu_count = 1
box_ram_mb = "2048"
### kubeadm parameters
master_ip = "192.168.77.10"
join_token = "7d0576.ee0f7f72653463dd"
worker_count = 3
### This can break compatibilty, use with care.
### Always make sure that kubeadm's version supports k8s version
### This is only for the control plane components,
### kubelet and kubeadm will always be the latest available version
kubernetes_version = "v1.10.2"
Vagrant.require_version ">= 2.0.0"
Vagrant.configure("2") do |config|
config.vm.box = box_base
config.vm.box_check_update = false
config.vm.provision "shell", path: "install.sh"
# use cache plugin if available
# https://github.com/fgrehm/vagrant-cachier
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
config.vm.provider "virtualbox" do |vb|
vb.cpus = box_cpu_count
vb.memory = box_ram_mb
end
# master node configuration
config.vm.define "kube-master", primary: true do |master|
master.vm.hostname = "kube-master"
master.vm.network "private_network", ip: master_ip
master.vm.provision "shell" do |s|
s.inline = "sed 's/127.0.0.1.*'$2'/'$1' '$2'/' -i /etc/hosts"
s.args = [master_ip, master.vm.hostname]
end
master.vm.provision "shell" do |s|
s.path = "master-setup.sh"
s.privileged = false
s.args = [master_ip, join_token, kubernetes_version]
end
master.vm.post_up_message = "Done. don't forget to modify the $KUBECONFIG env var to include the cluster conf file located in this folder"
end
# worker nodes configuration
(1..worker_count).each do |i|
config.vm.define "kube-worker#{i}" do |worker|
worker_ip = master_ip.split('.').tap{|arr| arr[-1] = arr[-1].to_i + i}.join('.')
worker.vm.hostname = "kube-worker#{i}"
worker.vm.network "private_network", ip: worker_ip
worker.vm.provision "shell" do |s|
s.inline = "sed 's/127.0.0.1.*'$2'/'$1' '$2'/' -i /etc/hosts"
s.args = [worker_ip, worker.vm.hostname]
end
worker.vm.provision "shell" do |s|
s.path = "worker-setup.sh"
s.args = [master_ip, join_token]
end
end
end
end