From 764bb4dbbbf89347b8c1924f05b23577c9dd2ce4 Mon Sep 17 00:00:00 2001
From: Peter Toth <peter.toth@univie.ac.at>
Date: Mon, 21 Nov 2022 14:14:59 +0000
Subject: [PATCH] Vagrantfile

---
 kube8s-containerd/Vagrantfile | 103 ++++++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 kube8s-containerd/Vagrantfile

diff --git a/kube8s-containerd/Vagrantfile b/kube8s-containerd/Vagrantfile
new file mode 100644
index 0000000..96378f3
--- /dev/null
+++ b/kube8s-containerd/Vagrantfile
@@ -0,0 +1,103 @@
+Vagrant.configure("2") do |config|
+  if Vagrant.has_plugin?("vagrant-timezone")
+    config.timezone.value = "Europe/Vienna"
+  end
+  # https://app.vagrantup.com/boxes/search?utf8=%E2%9C%93&sort=downloads&provider=virtualbox&q=jammy
+  config.vm.box = "ubuntu/jammy64"
+  config.vm.box_version = "20221120.0.0"
+  config.vm.box_url = "ubuntu/jammy64"
+  WORKERNODES = 2
+  config.vm.define "master-node" do |m| 
+    m.vm.hostname = "master-node"
+    m.vm.network "private_network", ip: "192.168.56.10"
+
+    m.vm.provider "virtualbox" do |vb|
+      # Display the VirtualBox GUI when booting the machine
+      # vb.gui = true
+
+      # Customize the amount of memory on the VM:
+      vb.memory = "2048"
+      vb.name = "master-node"
+    end
+    # the shell part of the k8s here
+    m.vm.provision "setup-hosts", :type => "shell", :path => "k8s-setup-master.sh" do |s|
+    end #of the shell part
+    m.vm.provision "setup-user", :type => "shell", :path => "adduser-sysopans.sh" do |s|
+    end #of the shell part
+    m.vm.provision "shell" do |s|
+      ssh_pub_key = File.readlines("/home/master/.ssh/sysopans-id_rsa.pub").first.strip
+      s.inline = <<-SHELL
+        echo #{ssh_pub_key} >> /home/sysopans/.ssh/authorized_keys
+      SHELL
+    end
+    m.vm.provision "setup-user-perm", :type => "shell", :path => "setpermission-sysopans.sh" do |s|
+    end #of the shell part
+    # m.vm.provision "shell", inline: <<-SHELL
+    #   apt-get update
+    #   apt-get install -y nginx
+    # SHELL
+  end # master-node
+  
+  (1..WORKERNODES).each do |i|
+  # worker-nodeX:
+  config.vm.define "worker-node#{i}" do |w|
+    w.vm.hostname = "worker-node#{i}"
+    w.vm.network "private_network", ip: "192.168.56.#{10+i}"
+
+    w.vm.provider "virtualbox" do |vb|
+      # Display the VirtualBox GUI when booting the machine
+      # vb.gui = true
+
+      # Customize the amount of memory on the VM:
+      vb.memory = "1024"
+      vb.name = "worker-node#{i}"
+    end
+    # the shell part of the k8s here
+    w.vm.provision "setup-hosts", :type => "shell", :path => "k8s-setup-master.sh" do |s|
+    end #of the shell part
+    w.vm.provision "setup-user", :type => "shell", :path => "adduser-sysopans.sh" do |s|
+    end #of the shell part
+    w.vm.provision "shell" do |s|
+      ssh_pub_key = File.readlines("/home/master/.ssh/sysopans-id_rsa.pub").first.strip
+      s.inline = <<-SHELL
+        echo #{ssh_pub_key} >> /home/sysopans/.ssh/authorized_keys
+      SHELL
+    end
+    w.vm.provision "setup-user-perm", :type => "shell", :path => "setpermission-sysopans.sh" do |s|
+    end #of the shell part
+    # w.vm.provision "shell", inline: <<-SHELL
+    #   apt-get update
+    #   apt-get install -y nginx
+    # SHELL
+  end # worker-nodeX
+  end # loop
+
+  # hapr-node:
+  config.vm.define "hapr-node" do |h|
+    h.vm.hostname = "hapr-node"
+    h.vm.network "private_network", ip: "192.168.56.9"
+
+    h.vm.provider "virtualbox" do |vb|
+      # Display the VirtualBox GUI when booting the machine
+      # vb.gui = true
+
+      # Customize the amount of memory on the VM:
+      vb.memory = "1024"
+      vb.name = "hapr-node"
+    end
+    h.vm.provision "shell", inline: <<-SHELL
+      apt-get update
+      apt-get install -y haproxy
+    SHELL
+    h.vm.provision "setup-user", :type => "shell", :path => "adduser-sysopans.sh" do |s|
+    end #of the shell part
+    h.vm.provision "shell" do |s|
+      ssh_pub_key = File.readlines("/home/master/.ssh/sysopans-id_rsa.pub").first.strip
+      s.inline = <<-SHELL
+        echo #{ssh_pub_key} >> /home/sysopans/.ssh/authorized_keys
+      SHELL
+    end
+    h.vm.provision "setup-user-perm", :type => "shell", :path => "setpermission-sysopans.sh" do |s|
+    end #of the shell part
+  end # hapr-node
+end
-- 
GitLab