-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.py
113 lines (93 loc) · 3.26 KB
/
start.py
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env python3
import argparse
import platform
import subprocess
import sys
import time
from checklist import check_cluster_status, check_simpipe_pods_health
from install import install_or_upgrade_simpipe
from install import main as install_main
def start_colima(cpu, memory):
print("⏳ Starting colima...")
arch = platform.machine()
if arch == "arm64":
arch = "aarch64"
elif arch != "x86_64":
print("❌ Unsupported architecture: " + arch)
sys.exit(1)
subprocess.run(
[
"colima",
"start",
"--kubernetes",
# Uncomment the following line if you want to use the MacOS VM framework
# instead of qemu.
# "--vm-type=vz",
# "--vz-rosetta",
# If using the MacOS VM framework, the following line will ignore IPv6
# as IPv6 is problematic on some networks.
# See https://github.com/abiosoft/colima/issues/648
# "--dns=192.168.5.3",
"--cpu",
str(cpu),
"--memory",
str(memory),
# set the current docker/kubernetes context
"--activate",
"--arch",
arch,
"simpipe",
],
check=True,
)
def main():
parser = argparse.ArgumentParser(
description="Start SIM-PIPE on your local machine."
)
parser.add_argument(
"--cpu", type=int, help="Number of CPU cores (mac only).", default=4
)
parser.add_argument(
"--memory", type=int, help="Amount of memory in GB (mac only).", default=6
)
args = parser.parse_args()
install_main()
if platform.system() == "Darwin":
start_colima(cpu=args.cpu, memory=args.memory)
else:
# Check if we can read the Kubernetes config file
try:
subprocess.run(
["kubectl", "config", "view"], check=True, capture_output=True
)
except subprocess.CalledProcessError:
print("❌ Unable to read Kubernetes config file.")
print("Consider logging out, logging in, and run this script again.")
sys.exit(1)
kubernetes_has_started = check_cluster_status(silent=True)
if not kubernetes_has_started:
print(
"😫 This script only starts Kubernetes automatically on macOS for now."
)
print("Please start your Kubernetes cluster manually.")
nb_tentatives = 0
while not check_cluster_status(silent=True):
print("😴 Waiting for Kubernetes cluster to be ready...")
nb_tentatives += 1
if nb_tentatives > 8:
if not check_cluster_status(silent=False):
sys.exit(1)
time.sleep(5)
print("🎉 the kubernetes cluster is ready.")
install_or_upgrade_simpipe()
nb_tentatives = 0
while not check_simpipe_pods_health(silent=True):
print("😴 Waiting for simpipe pods to be ready...")
nb_tentatives += 1
if nb_tentatives > 8:
if not check_simpipe_pods_health(silent=False):
sys.exit(1)
time.sleep(5)
print("🚀 simpipe is ready.")
if __name__ == "__main__":
main()