11#! /bin/bash
2- # Deploy MaaS platform locally on a Kind cluster (Mac only ).
2+ # Deploy MaaS platform locally on a Kind cluster (macOS + Linux/WSL2 ).
33#
44# One-click deployment of: Kind + Istio + Gateway API + cert-manager +
55# Kuadrant (auth/rate-limiting) + PostgreSQL + MaaS controller + MaaS API.
@@ -95,7 +95,7 @@ while [[ $# -gt 0 ]]; do
9595 --help|-h)
9696 echo " Usage: $0 [--teardown | --status | --validate | --rebuild <component> | --help]"
9797 echo " "
98- echo " Deploy MaaS platform on a local Kind cluster (Mac only )."
98+ echo " Deploy MaaS platform on a local Kind cluster (macOS + Linux/WSL2 )."
9999 echo " "
100100 echo " Flags:"
101101 echo " --teardown Delete the Kind cluster and all resources"
382382
383383step " Checking prerequisites"
384384
385- # Mac only
386- if [[ " $( uname -s) " != " Darwin" ]]; then
387- fail " This script only supports macOS. Detected: $( uname -s) "
385+ # Supported platforms: macOS and Linux (including WSL2)
386+ OS=" $( uname -s) "
387+ if [[ " $OS " != " Darwin" && " $OS " != " Linux" ]]; then
388+ fail " This script supports macOS and Linux. Detected: $OS "
388389 exit 1
389390fi
390- ok " macOS detected ($ARCH )"
391+ ok " $OS detected ($ARCH )"
391392
392- # Docker Desktop
393+ # Docker
393394if ! docker info & > /dev/null; then
394- fail " Docker is not running. Start Docker Desktop and try again."
395+ fail " Docker is not running. Start Docker ( Desktop or daemon) and try again."
395396 exit 1
396397fi
397398
@@ -412,7 +413,11 @@ else
412413fi
413414
414415# Check disk space
415- DISK_FREE_GB=$( df -g / | tail -1 | awk ' {print $4}' )
416+ if [[ " $OS " == " Darwin" ]]; then
417+ DISK_FREE_GB=$( df -g / | tail -1 | awk ' {print $4}' )
418+ else
419+ DISK_FREE_GB=$( df --block-size=1G / | tail -1 | awk ' {print $4}' )
420+ fi
416421if [[ " $DISK_FREE_GB " -lt 10 ]]; then
417422 warn " Only ${DISK_FREE_GB} GB free disk space. Recommend 10+ GB."
418423else
@@ -429,7 +434,11 @@ done
429434
430435if [[ ${# MISSING[@]} -gt 0 ]]; then
431436 fail " Missing required tools: ${MISSING[*]} "
432- echo " Install with: brew install ${MISSING[*]} "
437+ if [[ " $OS " == " Darwin" ]]; then
438+ echo " Install with: brew install ${MISSING[*]} "
439+ else
440+ echo " Install with your package manager (e.g., apt install ${MISSING[*]} )"
441+ fi
433442 exit 1
434443fi
435444ok " Tools: kind, kubectl, kustomize, helm, jq"
@@ -512,10 +521,15 @@ else
512521 fi
513522 kubectl wait --for=condition=Available deployment/controller -n metallb-system --timeout=120s
514523
524+ # Wait for webhook pod to be ready before applying config (avoids race condition)
525+ kubectl wait --for=condition=Ready pod -l component=controller -n metallb-system --timeout=120s 2> /dev/null || true
526+
515527 # Configure IP pool from Kind's docker network (extract IPv4 subnet)
516528 KIND_SUBNET=$( docker network inspect kind -f ' {{range .IPAM.Config}}{{.Subnet}} {{end}}' | tr ' ' ' \n' | grep ' \.' )
517529 LB_BASE=$( echo " $KIND_SUBNET " | cut -d' .' -f1-3)
518- kubectl apply -f - << EOF
530+ _metallb_retries=0
531+ while [[ $_metallb_retries -lt 6 ]]; do
532+ if kubectl apply -f - << EOF 2>/dev/null
519533apiVersion: metallb.io/v1beta1
520534kind: IPAddressPool
521535metadata:
@@ -531,6 +545,13 @@ metadata:
531545 name: kind-l2
532546 namespace: metallb-system
533547EOF
548+ then
549+ break
550+ fi
551+ echo " MetalLB webhook not ready, retrying in 10s..."
552+ sleep 10
553+ _metallb_retries=$(( _metallb_retries + 1 ))
554+ done
534555 ok " MetalLB installed (LB range: ${LB_BASE} .200-250)"
535556fi
536557
@@ -544,6 +565,24 @@ else
544565 kubectl apply -f " https://github.com/cert-manager/cert-manager/releases/download/v${CERTMANAGER_VERSION} /cert-manager.yaml"
545566 kubectl wait --for=condition=Available deployment/cert-manager -n cert-manager --timeout=120s
546567 kubectl wait --for=condition=Available deployment/cert-manager-webhook -n cert-manager --timeout=120s
568+ # Wait for webhook to actually serve (deployment Available != TLS endpoint ready)
569+ echo " Waiting for cert-manager webhook to serve..."
570+ _cm_retries=0
571+ while [[ $_cm_retries -lt 12 ]]; do
572+ if kubectl apply --dry-run=server -f - << CMEOF 2>/dev/null
573+ apiVersion: cert-manager.io/v1
574+ kind: ClusterIssuer
575+ metadata:
576+ name: cert-manager-webhook-test
577+ spec:
578+ selfSigned: {}
579+ CMEOF
580+ then
581+ break
582+ fi
583+ sleep 5
584+ _cm_retries=$(( _cm_retries + 1 ))
585+ done
547586 ok " cert-manager v${CERTMANAGER_VERSION} installed"
548587fi
549588
0 commit comments