forked from ethpandaops/ethereum-package
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlaunch.sh
executable file
·93 lines (77 loc) · 3.45 KB
/
launch.sh
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
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
# Get the directory of the current script
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "$SCRIPT_DIR/utils.sh"
# Function to check if the image is loaded in Minikube
check_image_in_minikube() {
local image_key=$1
local config_yaml=$2
# extract image name from the YAML file
printf "Check if %s is present in %s...\n" "$image_key" "$config_yaml"
local image=$(grep -E '(^|\s)"$image_key"' "$config_yaml" | awk '{print $2}')
if minikube image ls | grep -q "$image"; then
echo "$image is already loaded in Minikube."
else
echo "$image is NOT found in Minikube. Please build them and load them into Minikube.
Consider use the following command:
docker build -f Dockerfile -t "$image" . && minikube image load "$image"
"
return 1
fi
}
# Main script execution
# Check if minikube is installed
check_installation "minikube"
# check if minikube is running
if minikube status -f "{{.Host}}" | grep -q "Running"; then
echo "Minikube has already been running."
else
echo "Minikube is not running. Starting Minikube..."
# Start minikube
minikube start --driver=docker --memory=8196 --cpus=2 --extra-config=kube-proxy.mode=iptables --extra-config=kubelet.sync-frequency=0.5m --extra-config=kubelet.eviction-hard="memory.available<500Mi,nodefs.available<10%" --wait-timeout=10m && eval $(minikube -p minikube docker-env)
if [ $? -eq 0 ]; then
echo "Minikube started successfully."
else
echo "🚨 Failed to start Minikube."
exit 1
fi
fi
echo "💡 Please follow https://docs.kurtosis.com/k8s to configure kurtosis for minikube.
"
# Check if the images are loaded in Minikube
all_images_loaded=true
check_image_in_minikube "mev_relay_image" "$SCRIPT_DIR/network_params.yaml" || all_images_loaded=false
check_image_in_minikube "mev_builder_cl_image" "$SCRIPT_DIR/network_params.yaml" || all_images_loaded=false
# Print a message if any images are missing
if [ "$all_images_loaded" = false ]; then
echo "🚨 Please build and load the missing images into Minikube.
"
fi
# setup metrics for minikube
minikube addons enable metrics-server
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard
kubectl apply -f "$SCRIPT_DIR/static_files/kubernetes-config/dashboard-admin-user-creation.yaml"
kubectl apply -f "$SCRIPT_DIR/static_files/kubernetes-config/dashboard-admin-user-binding.yaml"
kubectl apply -f "$SCRIPT_DIR/static_files/kubernetes-config/dashboard-admin-user-secret.yaml"
# launch kurtosis
echo "
💡 Please open a new terminal tab and run:
kurtosis engine start && kurtosis gateway
"
# launch the network
echo "💡 Please open a new terminal tab and run:
source "$SCRIPT_DIR/utils.sh" && kurtosis --enclave relaytestnet run "$SCRIPT_DIR" --args-file "$SCRIPT_DIR/network_params.yaml"
"
# Run some network tests
echo "💡 Once the kurtosis network is running, you can run some network tests:
1. Launch a ping test: \`launch_ping_test\`
2. Launch a syn flood attack: \`launch_syn_flood_test\`
3. Launch attacknet: \`launch_attacknet\`
"
# port forward the dashboard
if kubectl -n kubernetes-dashboard get svc &> /dev/null | grep -q "kubernetes-dashboard-kong-proxy"; then
echo "Kubernetes dashboard is already port forwarded."
else
kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-kong-proxy 8443:443
fi