mirror of
https://github.com/biersoeckli/QuickStack.git
synced 2026-02-10 13:39:07 -06:00
fix/update network interface selection in setup scripts
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# QuickStack
|
||||
# QuickStack
|
||||
|
||||
QuickStack is a open source self-hosted Platform-as-a-Service (PaaS) solution designed to simplify the management of containerized applications on Virtual Private Server (VPS) infrastructures.
|
||||
Developed as part of a student project at the [Eastern Switzerland University of Applied Sciences](https://ost.ch/), QuickStack provides a scalable and cost-effective alternative to commercial cloud PaaS offerings like Vercel, Digital Ocean App Platform or Azure App Service.
|
||||
@@ -24,7 +24,7 @@ Before getting started, ensure that you have:
|
||||
1. **Connect to your VPS via SSH.**
|
||||
2. **Run the setup script:**
|
||||
```bash
|
||||
curl -sfL https://get.quickstack.dev/setup.sh | sh
|
||||
curl -sfL https://get.quickstack.dev/setup.sh | sh -
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -3,58 +3,59 @@
|
||||
# curl -sfL https://get.quickstack.dev/setup-worker.sh | K3S_URL=<https://IP-ADDRESS-OR-HOSTNAME-OF-MASTERNODE:6443> JOIN_TOKEN=<TOKEN> sh -
|
||||
|
||||
if [ -z "${K3S_URL}" ]; then
|
||||
echo "Error: Missing parameter 'K3S_URL'."
|
||||
echo "Example K3S_URL https://<IP-ADDRESS-OR-HOSTNAME-OF-MASTERNODE>:6443"
|
||||
exit 1
|
||||
echo "Error: Missing parameter 'K3S_URL'."
|
||||
echo "Example K3S_URL https://<IP-ADDRESS-OR-HOSTNAME-OF-MASTERNODE>:6443"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${JOIN_TOKEN}" ]; then
|
||||
echo "Error: Missing parameter 'JOIN_TOKEN'."
|
||||
exit 1
|
||||
echo "Error: Missing parameter 'JOIN_TOKEN'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
k3sUrl="$1"
|
||||
joinToken="$2"
|
||||
|
||||
|
||||
select_network_interface() {
|
||||
echo "Detecting network interfaces with IPv4 addresses..."
|
||||
interfaces_with_ips=$(ip -o -4 addr show | awk '{print $2, $4}' | sort -u)
|
||||
if [ -z "$INSTALL_K3S_INTERFACE" ]; then
|
||||
interfaces_with_ips=$(ip -o -4 addr show | awk '!/^[0-9]*: lo:/ {print $2, $4}' | cut -d'/' -f1)
|
||||
|
||||
if [ $(echo "$interfaces_with_ips" | wc -l) -eq 1 ]; then
|
||||
# If only one interface is found, use it by default
|
||||
selected_iface=$(echo "$interfaces_with_ips" | awk '{print $1}')
|
||||
selected_ip=$(echo "$interfaces_with_ips" | awk '{print $2}')
|
||||
echo "Only one network interface detected: $selected_iface ($selected_ip)"
|
||||
else
|
||||
echo "Available network interfaces:"
|
||||
echo "$interfaces_with_ips"
|
||||
echo ""
|
||||
echo "*******************************************************************************************************"
|
||||
echo ""
|
||||
echo "Multiple network interfaces detected:"
|
||||
echo "Please select the ip address wich is in the same network as the master node."
|
||||
echo "If you havent configured a private network between the nodes, select the public ip address."
|
||||
echo ""
|
||||
options=()
|
||||
while read -r iface ip; do
|
||||
options+=("$iface ($ip)")
|
||||
done <<< "$interfaces_with_ips"
|
||||
|
||||
PS3="Please select the network interface to use: "
|
||||
select entry in "${options[@]}"; do
|
||||
if [ -n "$entry" ]; then
|
||||
selected_iface=$(echo "$entry" | awk -F' ' '{print $1}')
|
||||
selected_ip=$(echo "$entry" | awk -F'[()]' '{print $2}')
|
||||
echo "Selected interface: $selected_iface ($selected_ip)"
|
||||
break
|
||||
else
|
||||
echo "Invalid selection. Please try again."
|
||||
fi
|
||||
i=1
|
||||
echo "$interfaces_with_ips" | while read -r iface ip; do
|
||||
printf "%d) %s (%s)\n" "$i" "$iface" "$ip"
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
printf "Please enter the number of the interface to use (1-%d): " "$((i-1))"
|
||||
# Change read to use /dev/tty explicitly
|
||||
read -r choice </dev/tty
|
||||
|
||||
selected=$(echo "$interfaces_with_ips" | sed -n "${choice}p")
|
||||
selected_iface=$(echo "$selected" | awk '{print $1}')
|
||||
selected_ip=$(echo "$selected" | awk '{print $2}')
|
||||
|
||||
if [ -n "$selected" ]; then
|
||||
echo "Selected interface: $selected_iface ($selected_ip)"
|
||||
else
|
||||
echo "Invalid selection. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Using network interface: $selected_iface with IP address: $selected_ip"
|
||||
}
|
||||
|
||||
# Call the function to select the network interface
|
||||
select_network_interface
|
||||
|
||||
# install nfs-common and open-iscsi
|
||||
sudo apt-get update
|
||||
@@ -68,4 +69,4 @@ echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------------"
|
||||
echo "* Node Setup completed. It might take a few minutes until the node is visible in the QuickStack settings. *"
|
||||
echo "-----------------------------------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
echo ""
|
||||
|
||||
121
setup/setup.sh
121
setup/setup.sh
@@ -3,78 +3,78 @@
|
||||
# curl -sfL https://get.quickstack.dev/setup.sh | sh -
|
||||
|
||||
select_network_interface() {
|
||||
echo "Detecting network interfaces with IPv4 addresses..."
|
||||
interfaces_with_ips=$(ip -o -4 addr show | awk '{print $2, $4}' | sort -u)
|
||||
if [ -z "$INSTALL_K3S_INTERFACE" ]; then
|
||||
interfaces_with_ips=$(ip -o -4 addr show | awk '!/^[0-9]*: lo:/ {print $2, $4}' | cut -d'/' -f1)
|
||||
|
||||
if [ $(echo "$interfaces_with_ips" | wc -l) -eq 1 ]; then
|
||||
# If only one interface is found, use it by default
|
||||
selected_iface=$(echo "$interfaces_with_ips" | awk '{print $1}')
|
||||
selected_ip=$(echo "$interfaces_with_ips" | awk '{print $2}')
|
||||
echo "Only one network interface detected: $selected_iface ($selected_ip)"
|
||||
echo "Available network interfaces:"
|
||||
echo "$interfaces_with_ips"
|
||||
echo ""
|
||||
echo "*******************************************************************************************************"
|
||||
echo ""
|
||||
echo "If you plan to use QuickStack in a cluster using multiple servers in multiple Networks (private/public),"
|
||||
echo "choose the network Interface you want to use for the communication between the servers."
|
||||
echo ""
|
||||
echo "If you plan to use QuickStack in a single server setup, choose the network Interface with the public IP."
|
||||
echo ""
|
||||
|
||||
i=1
|
||||
echo "$interfaces_with_ips" | while read -r iface ip; do
|
||||
printf "%d) %s (%s)\n" "$i" "$iface" "$ip"
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
printf "Please enter the number of the interface to use (1-%d): " "$((i - 1))"
|
||||
# Change read to use /dev/tty explicitly
|
||||
read -r choice </dev/tty
|
||||
|
||||
selected=$(echo "$interfaces_with_ips" | sed -n "${choice}p")
|
||||
selected_iface=$(echo "$selected" | awk '{print $1}')
|
||||
selected_ip=$(echo "$selected" | awk '{print $2}')
|
||||
|
||||
if [ -n "$selected" ]; then
|
||||
echo "Selected interface: $selected_iface ($selected_ip)"
|
||||
else
|
||||
echo ""
|
||||
echo "*******************************************************************************************************"
|
||||
echo ""
|
||||
echo "Multiple network interfaces detected:"
|
||||
echo "If you plan to use QuickStack in a cluster using multiple servers in multiple Networks (private/public),"
|
||||
echo "choose the network Interface you want to use for the communication between the servers."
|
||||
echo ""
|
||||
echo "If you plan to use QuickStack in a single server setup, choose the network Interface with the public IP."
|
||||
echo ""
|
||||
options=()
|
||||
while read -r iface ip; do
|
||||
options+=("$iface ($ip)")
|
||||
done <<< "$interfaces_with_ips"
|
||||
|
||||
PS3="Please select the network interface to use: "
|
||||
select entry in "${options[@]}"; do
|
||||
if [ -n "$entry" ]; then
|
||||
selected_iface=$(echo "$entry" | awk -F' ' '{print $1}')
|
||||
selected_ip=$(echo "$entry" | awk -F'[()]' '{print $2}')
|
||||
echo "Selected interface: $selected_iface ($selected_ip)"
|
||||
break
|
||||
else
|
||||
echo "Invalid selection. Please try again."
|
||||
fi
|
||||
done
|
||||
echo "Invalid selection. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Using network interface: $selected_iface with IP address: $selected_ip"
|
||||
echo "Using network interface: $selected_iface with IP address: $selected_ip"
|
||||
}
|
||||
|
||||
wait_until_all_pods_running() {
|
||||
|
||||
# Waits another 5 seconds to make sure all pods are registered for the first time.
|
||||
sleep 5
|
||||
# Waits another 5 seconds to make sure all pods are registered for the first time.
|
||||
sleep 5
|
||||
|
||||
while true; do
|
||||
OUTPUT=$(sudo k3s kubectl get pods -A --no-headers 2>&1)
|
||||
while true; do
|
||||
OUTPUT=$(sudo k3s kubectl get pods -A --no-headers 2>&1)
|
||||
|
||||
# Checks if there are no resources found --> Kubernetes ist still starting up
|
||||
if echo "$OUTPUT" | grep -q "No resources found"; then
|
||||
echo "Kubernetes is still starting up..."
|
||||
else
|
||||
# Extracts the STATUS column from the kubectl output and filters out the values "Running" and "Completed".
|
||||
STATUS=$(echo "$OUTPUT" | awk '{print $4}' | grep -vE '^(Running|Completed)$')
|
||||
# Checks if there are no resources found --> Kubernetes ist still starting up
|
||||
if echo "$OUTPUT" | grep -q "No resources found"; then
|
||||
echo "Kubernetes is still starting up..."
|
||||
else
|
||||
# Extracts the STATUS column from the kubectl output and filters out the values "Running" and "Completed".
|
||||
STATUS=$(echo "$OUTPUT" | awk '{print $4}' | grep -vE '^(Running|Completed)$')
|
||||
|
||||
# If the STATUS variable is empty, all pods are running and the loop can be exited.
|
||||
if [ -z "$STATUS" ]; then
|
||||
echo "Pods started successfully."
|
||||
break
|
||||
else
|
||||
echo "Waiting for all pods to come online..."
|
||||
fi
|
||||
fi
|
||||
# If the STATUS variable is empty, all pods are running and the loop can be exited.
|
||||
if [ -z "$STATUS" ]; then
|
||||
echo "Pods started successfully."
|
||||
break
|
||||
else
|
||||
echo "Waiting for all pods to come online..."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Waits for X seconds before checking the pod status again.
|
||||
sleep 10
|
||||
done
|
||||
# Waits for X seconds before checking the pod status again.
|
||||
sleep 10
|
||||
done
|
||||
|
||||
# Waits another 5 seconds to make sure all pods are ready.
|
||||
sleep 5
|
||||
# Waits another 5 seconds to make sure all pods are ready.
|
||||
sleep 5
|
||||
|
||||
sudo kubectl get node
|
||||
sudo kubectl get pods -A
|
||||
sudo kubectl get node
|
||||
sudo kubectl get pods -A
|
||||
}
|
||||
|
||||
# Prompt for network interface
|
||||
@@ -118,11 +118,10 @@ sudo kubectl -n cert-manager get pod
|
||||
sudo apt-get install jq -y
|
||||
sudo curl -sSfL https://raw.githubusercontent.com/longhorn/longhorn/v1.7.2/scripts/environment_check.sh | bash
|
||||
|
||||
|
||||
joinTokenForOtherNodes=$(sudo cat /var/lib/rancher/k3s/server/node-token)
|
||||
|
||||
# deploy QuickStack
|
||||
cat <<EOF > quickstack-setup-job.yaml
|
||||
cat <<EOF >quickstack-setup-job.yaml
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
@@ -176,4 +175,4 @@ sudo kubectl logs -f job/quickstack-setup-job -n quickstack
|
||||
|
||||
# evaluate url to add node to cluster
|
||||
# echo "To add an additional node to the cluster, run the following command on the worker node:"
|
||||
# echo "curl -sfL https://get.quickstack.dev/setup-worker.sh | K3S_URL=https://<IP-ADDRESS-OR-HOSTNAME-OF-MASTERNODE>:6443 JOIN_TOKEN=$joinTokenForOtherNodes sh -"
|
||||
# echo "curl -sfL https://get.quickstack.dev/setup-worker.sh | K3S_URL=https://<IP-ADDRESS-OR-HOSTNAME-OF-MASTERNODE>:6443 JOIN_TOKEN=$joinTokenForOtherNodes sh -"
|
||||
|
||||
@@ -13,7 +13,7 @@ export default function AddClusterNodeDialog({ children, clusterJoinToken }: { c
|
||||
const [command, setCommand] = useState<string>(``);
|
||||
|
||||
useEffect(() => {
|
||||
setCommand(`curl -sfL https://get.quickstack.dev/setup-worker.sh | K3S_URL=https://MASTER-IP:6443 JOIN_TOKEN=${clusterJoinToken ?? ''} sh -`);
|
||||
setCommand(`curl -sfL https://get.quickstack.dev/setup-worker.sh | K3S_URL=https://MASTER_IP:6443 JOIN_TOKEN=${clusterJoinToken ?? ''} sh -`);
|
||||
}, [clusterJoinToken]);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user