diff --git a/README.md b/README.md index e426367..d405446 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/setup/setup-worker.sh b/setup/setup-worker.sh index 3165ac6..d1a7b75 100644 --- a/setup/setup-worker.sh +++ b/setup/setup-worker.sh @@ -3,58 +3,59 @@ # curl -sfL https://get.quickstack.dev/setup-worker.sh | K3S_URL= JOIN_TOKEN= sh - if [ -z "${K3S_URL}" ]; then - echo "Error: Missing parameter 'K3S_URL'." - echo "Example K3S_URL https://:6443" - exit 1 + echo "Error: Missing parameter 'K3S_URL'." + echo "Example K3S_URL https://: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 &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 < quickstack-setup-job.yaml +cat <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://:6443 JOIN_TOKEN=$joinTokenForOtherNodes sh -" \ No newline at end of file +# echo "curl -sfL https://get.quickstack.dev/setup-worker.sh | K3S_URL=https://:6443 JOIN_TOKEN=$joinTokenForOtherNodes sh -" diff --git a/src/app/settings/cluster/add-cluster-node-dialog.tsx b/src/app/settings/cluster/add-cluster-node-dialog.tsx index 3410c6f..abd0aa9 100644 --- a/src/app/settings/cluster/add-cluster-node-dialog.tsx +++ b/src/app/settings/cluster/add-cluster-node-dialog.tsx @@ -13,7 +13,7 @@ export default function AddClusterNodeDialog({ children, clusterJoinToken }: { c const [command, setCommand] = useState(``); 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 (