From babac2b31df7af1c1866e7bc66f8bb885842f317 Mon Sep 17 00:00:00 2001 From: Brad Swain Date: Tue, 29 Jul 2025 21:40:18 +0000 Subject: [PATCH 1/5] scale minikube resources based on system --- deployment/crs-architecture.sh | 44 +++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/deployment/crs-architecture.sh b/deployment/crs-architecture.sh index 6d987b0d..441cebdc 100755 --- a/deployment/crs-architecture.sh +++ b/deployment/crs-architecture.sh @@ -94,7 +94,49 @@ up() { ;; *) echo -e "${BLU}Deploying minikube cluster${NC}" - minikube status | grep -q "Running" || minikube start --force --extra-config=kubeadm.skip-phases=preflight --cpus=8 --memory=32g --disk-size=80g --driver=docker --kubernetes-version=stable + + # Detect system resources and adjust minikube parameters + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + AVAILABLE_CPUS=$(sysctl -n hw.ncpu) + AVAILABLE_MEMORY_BYTES=$(sysctl -n hw.memsize) + AVAILABLE_MEMORY_MB=$((AVAILABLE_MEMORY_BYTES / 1024 / 1024)) + else + # Linux + AVAILABLE_CPUS=$(nproc) + AVAILABLE_MEMORY_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}') + AVAILABLE_MEMORY_MB=$((AVAILABLE_MEMORY_KB / 1024)) + fi + + # Calculate safe limits (leave 25% for system) + MINIKUBE_CPUS=$((AVAILABLE_CPUS > 7 ? 8 : AVAILABLE_CPUS > 4 ? AVAILABLE_CPUS - 1 : AVAILABLE_CPUS)) + MINIKUBE_MEMORY_MB=$((AVAILABLE_MEMORY_MB * 75 / 100)) + + # Check if system meets minimum requirements + if [ $AVAILABLE_CPUS -lt 2 ]; then + echo -e "${RED}Error: System has only ${AVAILABLE_CPUS} CPU(s), but Buttercup requires at least 2 CPUs${NC}" + echo -e "${RED}Please use a machine with more CPU cores${NC}" + exit 1 + fi + + AVAILABLE_MEMORY_GB=$((AVAILABLE_MEMORY_MB / 1024)) + if [ $AVAILABLE_MEMORY_MB -lt 16384 ]; then # Need 16GB total for Buttercup components + echo -e "${RED}Error: System has only ${AVAILABLE_MEMORY_GB}GB RAM, but Buttercup requires at least 16GB${NC}" + echo -e "${RED}Please use a machine with more memory${NC}" + exit 1 + fi + + # Ensure minimum requirements for minikube + MINIKUBE_CPUS=$((MINIKUBE_CPUS < 2 ? 2 : MINIKUBE_CPUS)) + MINIKUBE_MEMORY_MB=$((MINIKUBE_MEMORY_MB < 4096 ? 4096 : MINIKUBE_MEMORY_MB)) + + MINIKUBE_MEMORY_GB=$((MINIKUBE_MEMORY_MB / 1024)) + + echo -e "${GRN}System resources: ${AVAILABLE_CPUS} CPUs, ${AVAILABLE_MEMORY_GB}GB RAM${NC}" + echo -e "${GRN}Minikube will use: ${MINIKUBE_CPUS} CPUs, ${MINIKUBE_MEMORY_GB}GB RAM${NC}" + echo -e "${BLU}Note: Recommended minimum is at least 8 CPUs and 64GB RAM${NC}" + + minikube status | grep -q "Running" || minikube start --force --extra-config=kubeadm.skip-phases=preflight --cpus=${MINIKUBE_CPUS} --memory=${MINIKUBE_MEMORY_MB}mb --disk-size=80g --driver=docker --kubernetes-version=stable echo -e "${GRN}Minikube cluster status:${NC}" minikube status From 16a38ec91f671a6f03edc4dc1b4d9fd5bcb63a64 Mon Sep 17 00:00:00 2001 From: Brad Swain Date: Tue, 29 Jul 2025 21:46:54 +0000 Subject: [PATCH 2/5] remove unreachable checks --- deployment/crs-architecture.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/deployment/crs-architecture.sh b/deployment/crs-architecture.sh index 441cebdc..09de7389 100755 --- a/deployment/crs-architecture.sh +++ b/deployment/crs-architecture.sh @@ -126,9 +126,6 @@ up() { exit 1 fi - # Ensure minimum requirements for minikube - MINIKUBE_CPUS=$((MINIKUBE_CPUS < 2 ? 2 : MINIKUBE_CPUS)) - MINIKUBE_MEMORY_MB=$((MINIKUBE_MEMORY_MB < 4096 ? 4096 : MINIKUBE_MEMORY_MB)) MINIKUBE_MEMORY_GB=$((MINIKUBE_MEMORY_MB / 1024)) From 7583e5cf15160c7e6322306fb34a04e9384b20c4 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Wed, 30 Jul 2025 19:52:35 +0000 Subject: [PATCH 3/5] Use docker system info for resource detection instead of OS-specific commands This ensures minikube gets accurate Docker-available resources rather than system-wide resources, which is especially important on macOS with Docker Desktop/Colima where Docker resources may be constrained. Co-authored-by: Brad Swain --- deployment/crs-architecture.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/deployment/crs-architecture.sh b/deployment/crs-architecture.sh index 09de7389..45d1634e 100755 --- a/deployment/crs-architecture.sh +++ b/deployment/crs-architecture.sh @@ -95,19 +95,19 @@ up() { *) echo -e "${BLU}Deploying minikube cluster${NC}" - # Detect system resources and adjust minikube parameters - if [[ "$OSTYPE" == "darwin"* ]]; then - # macOS - AVAILABLE_CPUS=$(sysctl -n hw.ncpu) - AVAILABLE_MEMORY_BYTES=$(sysctl -n hw.memsize) - AVAILABLE_MEMORY_MB=$((AVAILABLE_MEMORY_BYTES / 1024 / 1024)) - else - # Linux - AVAILABLE_CPUS=$(nproc) - AVAILABLE_MEMORY_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}') - AVAILABLE_MEMORY_MB=$((AVAILABLE_MEMORY_KB / 1024)) + # Detect Docker-available resources and adjust minikube parameters + echo -e "${BLU}Getting Docker system information...${NC}" + if ! docker system info > /dev/null 2>&1; then + echo -e "${RED}Error: Docker is not running or not accessible${NC}" + echo -e "${RED}Please ensure Docker is installed and running${NC}" + exit 1 fi + DOCKER_INFO=$(docker system info --format "{{.NCPU}},{{.MemTotal}}") + AVAILABLE_CPUS=$(echo "$DOCKER_INFO" | cut -d',' -f1) + AVAILABLE_MEMORY_BYTES=$(echo "$DOCKER_INFO" | cut -d',' -f2) + AVAILABLE_MEMORY_MB=$((AVAILABLE_MEMORY_BYTES / 1024 / 1024)) + # Calculate safe limits (leave 25% for system) MINIKUBE_CPUS=$((AVAILABLE_CPUS > 7 ? 8 : AVAILABLE_CPUS > 4 ? AVAILABLE_CPUS - 1 : AVAILABLE_CPUS)) MINIKUBE_MEMORY_MB=$((AVAILABLE_MEMORY_MB * 75 / 100)) @@ -129,7 +129,7 @@ up() { MINIKUBE_MEMORY_GB=$((MINIKUBE_MEMORY_MB / 1024)) - echo -e "${GRN}System resources: ${AVAILABLE_CPUS} CPUs, ${AVAILABLE_MEMORY_GB}GB RAM${NC}" + echo -e "${GRN}Docker-available resources: ${AVAILABLE_CPUS} CPUs, ${AVAILABLE_MEMORY_GB}GB RAM${NC}" echo -e "${GRN}Minikube will use: ${MINIKUBE_CPUS} CPUs, ${MINIKUBE_MEMORY_GB}GB RAM${NC}" echo -e "${BLU}Note: Recommended minimum is at least 8 CPUs and 64GB RAM${NC}" From 4cc838a4f4613b4d8aed3671365d6444d95aa6dd Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Thu, 31 Jul 2025 06:47:41 +0000 Subject: [PATCH 4/5] Address review feedback: update minimum resource thresholds - Increase minimum CPU requirement from 2 to 5 cores - Decrease minimum memory requirement from 16GB to 10GB for k8s cluster - Add proper variable quoting to fix shellcheck warnings Co-authored-by: Riccardo Schirone --- deployment/crs-architecture.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/crs-architecture.sh b/deployment/crs-architecture.sh index 45d1634e..8f5d2909 100755 --- a/deployment/crs-architecture.sh +++ b/deployment/crs-architecture.sh @@ -113,15 +113,15 @@ up() { MINIKUBE_MEMORY_MB=$((AVAILABLE_MEMORY_MB * 75 / 100)) # Check if system meets minimum requirements - if [ $AVAILABLE_CPUS -lt 2 ]; then - echo -e "${RED}Error: System has only ${AVAILABLE_CPUS} CPU(s), but Buttercup requires at least 2 CPUs${NC}" + if [ "$AVAILABLE_CPUS" -lt 5 ]; then + echo -e "${RED}Error: System has only ${AVAILABLE_CPUS} CPU(s), but Buttercup requires at least 5 CPUs${NC}" echo -e "${RED}Please use a machine with more CPU cores${NC}" exit 1 fi AVAILABLE_MEMORY_GB=$((AVAILABLE_MEMORY_MB / 1024)) - if [ $AVAILABLE_MEMORY_MB -lt 16384 ]; then # Need 16GB total for Buttercup components - echo -e "${RED}Error: System has only ${AVAILABLE_MEMORY_GB}GB RAM, but Buttercup requires at least 16GB${NC}" + if [ "$AVAILABLE_MEMORY_MB" -lt 10240 ]; then # Need 10GB dedicated to k8s cluster for Buttercup components + echo -e "${RED}Error: System has only ${AVAILABLE_MEMORY_GB}GB RAM, but Buttercup requires at least 10GB${NC}" echo -e "${RED}Please use a machine with more memory${NC}" exit 1 fi From 38c6f45b7b452b2eff8006cb3c1dced00e7ab833 Mon Sep 17 00:00:00 2001 From: Riccardo Schirone <562321+ret2libc@users.noreply.github.com> Date: Thu, 31 Jul 2025 09:22:38 +0200 Subject: [PATCH 5/5] Update deployment/crs-architecture.sh --- deployment/crs-architecture.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/crs-architecture.sh b/deployment/crs-architecture.sh index 8f5d2909..99d02c33 100755 --- a/deployment/crs-architecture.sh +++ b/deployment/crs-architecture.sh @@ -131,7 +131,7 @@ up() { echo -e "${GRN}Docker-available resources: ${AVAILABLE_CPUS} CPUs, ${AVAILABLE_MEMORY_GB}GB RAM${NC}" echo -e "${GRN}Minikube will use: ${MINIKUBE_CPUS} CPUs, ${MINIKUBE_MEMORY_GB}GB RAM${NC}" - echo -e "${BLU}Note: Recommended minimum is at least 8 CPUs and 64GB RAM${NC}" + echo -e "${BLU}Note: Recommended minimum is at least 5 CPUs and 10GB RAM${NC}" minikube status | grep -q "Running" || minikube start --force --extra-config=kubeadm.skip-phases=preflight --cpus=${MINIKUBE_CPUS} --memory=${MINIKUBE_MEMORY_MB}mb --disk-size=80g --driver=docker --kubernetes-version=stable echo -e "${GRN}Minikube cluster status:${NC}"