update: Added Longhorn installation process and updated memory allocation for VMs

update: Added 'git' and 'vagrant' to required tools in pre-flight checks

fix: configured k3s install to use internal nic for flanel network

fix: corrected JSON formatting for config json

update: reduce VM memory allocation to 2GB, add Longhorn installation scripts and prerequisites, and implement checks for existing pods
This commit is contained in:
jon brookes 2025-08-16 18:00:28 +01:00
parent 1605aa4f90
commit 268e1a136b
8 changed files with 160 additions and 4 deletions

View file

@ -0,0 +1,35 @@
#!/usr/bin/env bash
# function to install infctl
install_infctl() {
echo "Installing infctl..."
# Add installation commands here
curl -L https://codeberg.org/headshed/infctl-cli/raw/branch/main/install.sh | bash
}
if ! command -v infctl &> /dev/null
then
echo "infctl could not be found, installing..."
install_infctl
fi
# base.json.example config.json.example
# https://codeberg.org/headshed/infctl-cli/raw/branch/main/base.json.example
# https://codeberg.org/headshed/infctl-cli/raw/branch/main/config.json.example
if [ ! -f "base.json" ]; then
echo "base.json not found in home directory, downloading..."
curl -o "base.json" https://codeberg.org/headshed/infctl-cli/raw/branch/main/base.json.example
fi
if [ ! -f "config.json" ]; then
echo "config.json not found in home directory, downloading..."
curl -o "config.json" https://codeberg.org/headshed/infctl-cli/raw/branch/main/config.json.example
fi
echo "infctl is installed and ready to use."

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
echo
echo "vagrant longhorn installation"
echo
ssh-add ~/.ssh/vm*_key
source /home/vagrant/ansible/venv/bin/activate
# Check if there are any pods in the longhorn-system namespace
if kubectl -n longhorn-system get pods --no-headers 2>/dev/null | grep -q '^[^ ]'; then
echo "Pods already exist in the longhorn-system namespace. Skipping installation."
exit 0
fi
# https://github.com/longhorn/longhorn/releases
# v1.8.1 in prod 1.9.1 is latest
LONGHORN_RELEASE="v1.8.1"
LONGHORN_RELEASE_URL="https://raw.githubusercontent.com/longhorn/longhorn/$LONGHORN_RELEASE/deploy/longhorn.yaml"
echo "Applying Longhorn release $LONGHORN_RELEASE..."
echo "Using Longhorn release URL: $LONGHORN_RELEASE_URL"
kubectl apply -f $LONGHORN_RELEASE_URL

View file

@ -0,0 +1,32 @@
#!/usr/bin/env bash
echo
echo "vagrant longhorn prerequisites"
echo
ssh-add ~/.ssh/vm*_key
source /home/vagrant/ansible/venv/bin/activate
ANSIBLE_SUPPRESS_INTERPRETER_DISCOVERY_WARNING=1 ANSIBLE_HOST_KEY_CHECKING=False ansible --inventory-file /home/vagrant/ansible/ansible_inventory.ini -m ping vm1,vm2,vm3
if [ $? -ne 0 ]; then
echo "Ansible ping failed. Please check your Vagrant VMs and network configuration."
exit 1
fi
echo "Ansible ping successful."
# Check if there are any pods in the longhorn-system namespace
if kubectl -n longhorn-system get pods --no-headers 2>/dev/null | grep -q '^[^ ]'; then
echo "Pods already exist in the longhorn-system namespace. Skipping installation."
exit 0
fi
exit
echo "Installing Longhorn prerequisites..."
# install_longhorn_prereqs.yaml
ANSIBLE_SUPPRESS_INTERPRETER_DISCOVERY_WARNING=1 ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook ~/ansible/install_longhorn_prereqs.yaml --inventory-file /home/vagrant/ansible/ansible_inventory.ini
if [ $? -ne 0 ]; then
echo "Ansible playbook failed. Please check the playbook and your inventory."
exit 1
fi

View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
echo
echo "wait for longhorn installation"
echo
ssh-add ~/.ssh/vm*_key
source /home/vagrant/ansible/venv/bin/activate
while true; do
not_ready=$(kubectl -n longhorn-system get pods --no-headers 2>/dev/null | grep -vE 'Running|Completed' | wc -l)
total=$(kubectl -n longhorn-system get pods --no-headers 2>/dev/null | wc -l)
if [[ $total -gt 0 && $not_ready -eq 0 ]]; then
echo "All Longhorn pods are ready."
break
fi
sleep 10
done