Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
373 changes: 373 additions & 0 deletions tutorial4/README.md

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions tutorial4/resources/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# https://developer.hashicorp.com/vagrant/docs/vagrantfile
Vagrant.configure("2") do |config|

# Define the box that all nodes will use
# List of boxes available at [[https://vagrantcloud.com/search]]
# Choosing bento over generic as its more lightweight
config.vm.box = "bento/rockylinux-9"
# config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/vagrant"

# Here we define node specific settings - [[https://developer.hashicorp.com/vagrant/docs/multi-machine]]
config.vm.define "headnode", primary: true do |headnode|
headnode.vm.hostname = "headnode"

# Define a VirtualBox internal network - [[https://developer.hashicorp.com/vagrant/docs/providers/virtualbox/networking#virtualbox-internal-network]]
headnode.vm.network "private_network", ip: "10.0.0.1", virtualbox__intnet: "intnet"

# VirtualBox specific settings - [[https://developer.hashicorp.com/vagrant/docs/providers/virtualbox]]
headnode.vm.provider "virtualbox" do |vb|
vb.name = "headnode"
vb.cpus = 2
vb.memory = "2048"
vb.gui = false
end

# Run the head node shell script automatically
headnode.vm.provision "shell", path: "./headnode-setup.sh"
# If you want to do any scripting: [[https://developer.hashicorp.com/vagrant/docs/provisioning/shell]]
# If you want to use Ansible: [[https://developer.hashicorp.com/vagrant/docs/provisioning/ansible_intro]]
end

config.vm.define "computenode", autostart: false do |computenode|
computenode.vm.hostname = "computenode"

# Disable vagrant attempting to communicate with the VM on startup
# computenode.vm.communicator = :none

# ":adapter =>1" adds the internal network adapater to spot 1,
# replacing the default nat network adapter vagrant adds,
# ensuring that there is only the internal network adapter.
computenode.vm.network "private_network", ip: "10.0.0.2", virtualbox__intnet: "intnet"

computenode.vm.provider "virtualbox" do |vb|
vb.name = "computenode1"
vb.cpus = 4
vb.memory = "4096"
vb.gui = false
end

# Run the compute node shell script automatically
computenode.vm.provision "shell", path: "./computenode-setup.sh"
end
end
27 changes: 27 additions & 0 deletions tutorial4/resources/computenode-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# Update system
sudo dnf update -y

# Install tools
sudo dnf install -y net-tools iproute vim nfs-utils

# Set hostname
sudo hostnamectl set-hostname computenode

# Detect NAT and internal network interfaces automatically
NAT_IF=$(ip -o link show | awk -F': ' '{print $2}' | grep -E 'enp0s3|eth0' | head -n1)
INT_IF=$(ip -o link show | awk -F': ' '{print $2}' | grep -E 'enp0s[0-9]+|eth[0-9]+' | tail -n1)

# Disable NAT interface so it doesn't interfere
sudo ip link set $NAT_IF down

# Configure internal network
sudo ip addr add 10.0.0.2/24 dev $INT_IF
sudo ip link set $INT_IF up

# Set default route via headnode
sudo ip route add default via 10.0.0.1 dev $INT_IF

# Add /etc/hosts entries for cluster nodes
echo "10.0.0.1 headnode" | sudo tee -a /etc/hosts
echo "10.0.0.2 computenode" | sudo tee -a /etc/hosts
40 changes: 40 additions & 0 deletions tutorial4/resources/headnode-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
# Update system
sudo dnf update -y

# Install necessary tools
sudo dnf install -y net-tools iproute traceroute vim nfs-utils iptables-services

# Set hostname (optional if done in Vagrantfile)
sudo hostnamectl set-hostname headnode

# Configure internal network
sudo ip addr add 10.0.0.1/24 dev enp0s8
sudo ip link set enp0s8 up

# Enable IP forwarding immediately and permanently
sudo sysctl -w net.ipv4.ip_forward=1
sudo bash -c "echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf"
sudo sysctl -p

# Clear existing rules to avoid conflicts
sudo iptables -F
sudo iptables -t nat -F
sudo iptables -X

# Set default policies
sudo iptables -P FORWARD ACCEPT

# NAT for compute nodes to reach the internet
sudo iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o enp0s3 -j MASQUERADE
sudo iptables -A FORWARD -i enp0s8 -o enp0s3 -j ACCEPT
sudo iptables -A FORWARD -i enp0s3 -o enp0s8 -m state --state RELATED,ESTABLISHED -j ACCEPT

# Save rules persistently
sudo service iptables save
sudo systemctl enable iptables
sudo systemctl restart iptables

# Add /etc/hosts entries for cluster nodes
echo "10.0.0.1 headnode" | sudo tee -a /etc/hosts
echo "10.0.0.2 computenode" | sudo tee -a /etc/hosts
Binary file added tutorial4/resources/vb-click-new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorial4/resources/vb-download-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorial4/resources/vb-etc-host.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorial4/resources/vb-nat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorial4/resources/vb-new-vm-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorial4/resources/vb-pinging.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorial4/resources/vb-port-forwarding-rules.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorial4/resources/vb-rocky-download.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorial4/resources/vb-topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.