-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathVagrantfile
75 lines (61 loc) · 2.23 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Edit the variables between lines 7-18:
# Find your bridge interface name, e.g. with ip add or ifconfig or ipconfig
BRIDGE_IF="enp3s0"
# This will be the fixed IP address of the virtual machine
IP_ADDR_NODE01="192.168.2.51"
# Optional: fixed IP for second virtual machine
IP_ADDR_NODE02="192.168.2.51"
#Also adjust the 6 variables in the script section:
$script = <<-SCRIPT
IP_ADDR_NODE01="192.168.2.51"
GATEWAY="192.168.2.254"
DNS="192.168.2.254"
CLUSTER="microbot-k8s"
SAN1="microbot"
SAN2="microbot.moonstreet.local"
echo "copy install script"
wget https://raw.githubusercontent.com/jacqinthebox/vagrant-kubernetes/master/kubernetes-vagrant-install.sh && chmod u=rwx kubernetes-vagrant-install.sh && chown vagrant.vagrant kubernetes-vagrant-install.sh
if [ ! -f /tmp/50-vagrant.yaml ]; then
echo "adding gateway"
cp /etc/netplan/50-vagrant.yaml /tmp/
cat << EOF >> /etc/netplan/50-vagrant.yaml
gateway4: $GATEWAY
nameservers:
addresses: [$DNS,9.9.9.9]
EOF
netplan --debug generate
netplan --debug apply
fi
echo "configuring SSH to allow passwords"
sed -i -e 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
echo "restarting ssh service"
service ssh restart
echo "sshd has been restarted"
echo "installing kubernetes"
echo "running command ./kubernetes-vagrant-install.sh ${CLUSTER} ${IP_ADDR_NODE01} ${SAN1} ${SAN2}"
./kubernetes-vagrant-install.sh $CLUSTER $IP_ADDR_NODE01 $SAN1 $SAN2
SCRIPT
Vagrant.configure("2") do |config|
config.vm.define "node01" do |node01_config|
node01_config.vm.box = "ubuntu/bionic64"
node01_config.vm.hostname = "node01"
node01_config.vm.network "public_network", bridge: BRIDGE_IF, ip: IP_ADDR_NODE01
node01_config.vm.provider "virtualbox" do |v|
v.linked_clone = true
v.memory = 8192
end
end
# optional 2nd node
config.vm.define "node02" do |node02_config|
node02_config.vm.box = "ubuntu/bionic64"
node02_config.vm.hostname = "node02"
node02_config.vm.network "public_network", bridge: BRIDGE_IF, ip: IP_ADDR_NODE02
node02_config.vm.provider "virtualbox" do |v|
v.linked_clone = true
v.memory = 8192
end
end
config.vm.provision "shell", inline: $script
end