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:
parent
1605aa4f90
commit
268e1a136b
8 changed files with 160 additions and 4 deletions
|
|
@ -15,5 +15,5 @@
|
||||||
"nginx_conf": "path_to/conf.d",
|
"nginx_conf": "path_to/conf.d",
|
||||||
"admin_url": "admin_url.headshed.dev",
|
"admin_url": "admin_url.headshed.dev",
|
||||||
"preview_url": "app-prv.headshed.dev",
|
"preview_url": "app-prv.headshed.dev",
|
||||||
"ui_url": "ww2.headshed.dev",
|
"ui_url": "ww2.headshed.dev"
|
||||||
}
|
}
|
||||||
10
vagrant/dev/ubuntu/Vagrantfile
vendored
10
vagrant/dev/ubuntu/Vagrantfile
vendored
|
|
@ -34,7 +34,7 @@ Vagrant.configure("2") do |config|
|
||||||
end
|
end
|
||||||
|
|
||||||
vm1.vm.provider "virtualbox" do |vb|
|
vm1.vm.provider "virtualbox" do |vb|
|
||||||
vb.memory = "4096" # 4GB memory
|
vb.memory = "2048" # 4GB memory
|
||||||
vb.cpus = 2
|
vb.cpus = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -61,7 +61,11 @@ Vagrant.configure("2") do |config|
|
||||||
end
|
end
|
||||||
|
|
||||||
vm2.vm.provider "virtualbox" do |vb|
|
vm2.vm.provider "virtualbox" do |vb|
|
||||||
|
<<<<<<< HEAD
|
||||||
vb.memory = "4096" # 4GB memory
|
vb.memory = "4096" # 4GB memory
|
||||||
|
=======
|
||||||
|
vb.memory = "2048" # 4GB memory
|
||||||
|
>>>>>>> 8396e72 (update: Added Longhorn installation process and updated memory allocation for VMs)
|
||||||
vb.cpus = 2
|
vb.cpus = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -88,7 +92,11 @@ Vagrant.configure("2") do |config|
|
||||||
end
|
end
|
||||||
|
|
||||||
vm3.vm.provider "virtualbox" do |vb|
|
vm3.vm.provider "virtualbox" do |vb|
|
||||||
|
<<<<<<< HEAD
|
||||||
vb.memory = "4096" # 4GB memory
|
vb.memory = "4096" # 4GB memory
|
||||||
|
=======
|
||||||
|
vb.memory = "2048" # 4GB memory
|
||||||
|
>>>>>>> 8396e72 (update: Added Longhorn installation process and updated memory allocation for VMs)
|
||||||
vb.cpus = 2
|
vb.cpus = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,17 @@ sudo -u vagrant mkdir -p /home/vagrant/.ansible
|
||||||
sudo -u vagrant touch /home/vagrant/.ansible/ansible.cfg
|
sudo -u vagrant touch /home/vagrant/.ansible/ansible.cfg
|
||||||
|
|
||||||
# Create workspace and SSH directories
|
# Create workspace and SSH directories
|
||||||
sudo -u vagrant mkdir -p /home/vagrant/ansible
|
|
||||||
sudo -u vagrant mkdir -p /home/vagrant/.ssh
|
sudo -u vagrant mkdir -p /home/vagrant/.ssh
|
||||||
sudo chmod 700 /home/vagrant/.ssh
|
sudo chmod 700 /home/vagrant/.ssh
|
||||||
|
|
||||||
|
# create directories and copy files to /home/vagrant
|
||||||
|
mkdir -p /home/vagrant/{ansible,scripts,pipelines,k8s}
|
||||||
|
sudo cp -r /vagrant/ansible/* /home/vagrant/ansible/
|
||||||
|
sudo cp -r /vagrant/scripts/* /home/vagrant/scripts/
|
||||||
|
sudo cp -r /vagrant/pipelines/* /home/vagrant/pipelines
|
||||||
|
sudo cp -r /vagrant/k8s/* /home/vagrant/k8s
|
||||||
|
sudo chmod +x /home/vagrant/pipelines/*.sh
|
||||||
|
|
||||||
# Copy the Vagrant private keys (these will be synced by Vagrant)
|
# Copy the Vagrant private keys (these will be synced by Vagrant)
|
||||||
for i in {1..3}; do
|
for i in {1..3}; do
|
||||||
sudo -u vagrant cp /vagrant/.vagrant/machines/vm$i/virtualbox/private_key /home/vagrant/.ssh/vm${i}_key
|
sudo -u vagrant cp /vagrant/.vagrant/machines/vm$i/virtualbox/private_key /home/vagrant/.ssh/vm${i}_key
|
||||||
|
|
@ -81,7 +88,6 @@ if [ $? -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp -r /vagrant/ansible/* /home/vagrant/ansible/
|
|
||||||
|
|
||||||
eval `ssh-agent -s`
|
eval `ssh-agent -s`
|
||||||
ssh-add # ~/machines/*/virtualbox/private_key
|
ssh-add # ~/machines/*/virtualbox/private_key
|
||||||
|
|
@ -144,4 +150,11 @@ if [ $? -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# check infctl
|
||||||
|
cd /home/vagrant
|
||||||
|
bash /home/vagrant/scripts/check_install_infctl.sh
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "infctl check failed. Please check your installation."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
29
vagrant/dev/ubuntu/pipelines/vagrant-longhorn.json
Normal file
29
vagrant/dev/ubuntu/pipelines/vagrant-longhorn.json
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "Install Longhorn pre-requisites",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"./scripts/longhorn_prereqs.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 0,
|
||||||
|
"shouldAbort": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Install Longhorn",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"./scripts/install_longhorn.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 0,
|
||||||
|
"shouldAbort": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Wait for Longhorn pods to come up",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"./scripts/wait_for_longhorn.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 10,
|
||||||
|
"shouldAbort": true
|
||||||
|
}
|
||||||
|
]
|
||||||
35
vagrant/dev/ubuntu/scripts/check_install_infctl.sh
Executable file
35
vagrant/dev/ubuntu/scripts/check_install_infctl.sh
Executable 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."
|
||||||
22
vagrant/dev/ubuntu/scripts/install_longhorn.sh
Executable file
22
vagrant/dev/ubuntu/scripts/install_longhorn.sh
Executable 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
|
||||||
32
vagrant/dev/ubuntu/scripts/longhorn_prereqs.sh
Executable file
32
vagrant/dev/ubuntu/scripts/longhorn_prereqs.sh
Executable 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
|
||||||
17
vagrant/dev/ubuntu/scripts/wait_for_longhorn.sh
Executable file
17
vagrant/dev/ubuntu/scripts/wait_for_longhorn.sh
Executable 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue