-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·81 lines (69 loc) · 2.44 KB
/
install.sh
File metadata and controls
executable file
·81 lines (69 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
set -e
echo "🎮 K8sQuest Installation"
echo "========================"
echo ""
# Check prerequisites
command -v kind >/dev/null || { echo "❌ kind not found. Install with: brew install kind"; exit 1; }
command -v kubectl >/dev/null || { echo "❌ kubectl not found. Install with: brew install kubectl"; exit 1; }
command -v python3 >/dev/null || { echo "❌ python3 not found"; exit 1; }
# Verify Python version >= 3.9 (required for type hint syntax used in engine)
PYTHON_VERSION=$(python3 -c "import sys; v=sys.version_info; print(f'{v.major}.{v.minor}'); exit(0 if (v.major, v.minor) >= (3, 9) else 1)") || {
echo "❌ Python 3.9+ required, but found $PYTHON_VERSION"
echo " Install a newer Python:"
echo " macOS: brew install python@3.11"
echo " Linux: sudo apt install python3.11"
echo " Then ensure 'python3' resolves to 3.9+ (update PATH or alternatives)"
exit 1
}
echo "✅ Python $PYTHON_VERSION detected"
echo "✅ Prerequisites OK"
echo ""
# Create virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
echo "🐍 Creating Python virtual environment..."
python3 -m venv venv
if [ ! -d "venv" ]; then
echo "❌ Failed to create virtual environment"
exit 1
fi
fi
# Activate virtual environment and install dependencies
echo "📦 Installing Python dependencies..."
if [ -f "venv/bin/activate" ]; then
source venv/bin/activate
elif [ -f "venv/Scripts/activate" ]; then
source venv/Scripts/activate
else
echo "❌ Virtual environment activation script not found"
echo "Expected: venv/bin/activate or venv/Scripts/activate"
exit 1
fi
pip install -q -r requirements.txt
echo "✅ Python packages installed"
echo ""
# Create Kubernetes cluster
if ! kind get clusters | grep k8squest >/dev/null 2>&1; then
echo "🔧 Creating Kubernetes cluster..."
kind create cluster --name k8squest
else
echo "✅ Cluster already exists"
fi
kubectl config use-context kind-k8squest
# Create k8squest namespace
echo "🏗️ Setting up k8squest namespace..."
kubectl create namespace k8squest --dry-run=client -o yaml | kubectl apply -f -
# Setup RBAC for safety
echo "🛡️ Configuring safety guards (RBAC)..."
if [ -f "rbac/k8squest-rbac.yaml" ]; then
kubectl apply -f rbac/k8squest-rbac.yaml
echo "✅ Safety guards configured"
else
echo "⚠️ Warning: RBAC config not found, skipping"
fi
echo ""
echo "🚀 Setup Complete!"
echo ""
echo "To start playing, use the shortcut:"
echo " ./play.sh"
echo ""