Skip to content

Commit

Permalink
Add support for multi-node
Browse files Browse the repository at this point in the history
  • Loading branch information
bfournie committed Jan 7, 2025
1 parent 6e7b11c commit adf19dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
10 changes: 8 additions & 2 deletions agent/06_agent_create_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ function agent_iscsi_targets() {
local name=${1}-${n}
iscsi_disk=${SCRIPTDIR}/"iscsi-${name}"
agent_create_iscsi_target ${name} ${agent_iso} ${iscsi_disk}
agent_create_iscsi_pxe_file ${name} ${BOOT_SERVER_DIR}
agent_create_iscsi_pxe_file ${BOOT_SERVER_DIR}
done
}

Expand All @@ -390,7 +390,13 @@ function agent_iscsi_update_nodes() {
for (( n=0; n<${2}; n++ ))
do
local domain_name=${CLUSTER_NAME}_${1}_${n}
agent_add_iscsi_network_to_domain ${domain_name}
local name=${1}-${n}
local index=${n}
if [[ ${1} == "worker" ]]; then
index=+${NUM_MASTERS}
fi

agent_add_iscsi_network_to_domain ${domain_name} ${name} ${index}
domain_running=$(sudo virsh list)
if echo ${domain_running} | grep -q "${domain_name}"; then
sudo virsh destroy ${domain_name}
Expand Down
21 changes: 11 additions & 10 deletions agent/iscsi_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ source $SCRIPTDIR/agent/common.sh

function agent_add_iscsi_network_to_domain() {
local domain_name=${1}
local host_name=${2}
local index=${3}

# add the iscsi network
sudo virt-xml ${domain_name} --add-device --network network=${ISCSI_NETWORK},model=virtio,"boot_order=1"

# add the hostname binding so that the host can resolve the 'hostname' variable in pxe file
host_mac=$(sudo virsh domiflist ${domain_name} | grep ${ISCSI_NETWORK} | awk '{print $5}')
host_ip="192.168.145."${index}
sudo virsh net-update ${ISCSI_NETWORK} add-last ip-dhcp-host "<host mac='${host_mac}' name='${host_name}' ip='${host_ip}'/>"

# In order to boot from the iscsi network any other the
# boot configurations must be removed from the domain
# TODO - need to check if these exist before removing
# sudo virt-xml ${domain_name} --remove-device --disk device=cdrom,target.dev=sdc
# sudo virt-xml ${domain_name} --remove-device --disk device=disk,target.dev=sda

# set to boot from network
# Note - this should not be needed if boot_order is set for the iscsi network
# sudo virt-xml --edit --boot network ${domain_name}
}

function agent_create_iscsi_network() {
# TODO find macs and substitute them
# <host mac='52:54:00:a0:08:c6' name='ostest-worker-0' ip='192.168.145.20'/>
# <host mac='52:54:00:9e:f8:b3' name='ostest-worker-1' ip='192.168.145.21'/>
# TODO - remove hardcoded IP
cat <<EOF
<network>
Expand Down Expand Up @@ -78,12 +78,13 @@ function agent_create_iscsi_target() {

function agent_create_iscsi_pxe_file() {

local name=${1}
local boot_dir=${2}
local boot_dir=${1}

# Set 'hostname' variable in file. It will be resolved by host during PXE boot
# in order to access a unique target for this host.
cat > "${boot_dir}/agent.x86_64-iscsi.ipxe" << EOF
#!ipxe
set initiator-iqn iqn.2023-01.com.example:initiator01
sanboot --keep iscsi:192.168.145.1::::iqn.2023-01.com.example:${name}
sanboot --keep iscsi:192.168.145.1::::iqn.2023-01.com.example:\${hostname}
EOF
}

0 comments on commit adf19dd

Please sign in to comment.