@@ -151,6 +151,21 @@ def is_docker_desktop_running() -> tuple[bool, str]:
151
151
except FileNotFoundError as err :
152
152
return False , str (err )
153
153
154
+ def is_docker_desktop_kube_running () -> tuple [bool , str ]:
155
+ try :
156
+ cluster_info = subprocess .run (
157
+ ["kubectl" , "cluster-info" , "--request-timeout=1" ],
158
+ capture_output = True ,
159
+ text = True ,
160
+ )
161
+ if cluster_info .returncode == 0 :
162
+ return True , f"\n \t { cluster_info .stdout .strip ().replace ('\n ' , '\n \t ' )} "
163
+ else :
164
+ return False , ""
165
+ except Exception :
166
+ print ()
167
+ return False , "Please enable kubernetes in Docker Desktop"
168
+
154
169
def is_kubectl_installed_and_offer_if_not () -> tuple [bool , str ]:
155
170
try :
156
171
version_result = subprocess .run (
@@ -264,6 +279,12 @@ def check_installation(tool_info: ToolInfo) -> ToolStatus:
264
279
install_instruction = "Please make sure docker is running" ,
265
280
install_url = "https://docs.docker.com/engine/install/" ,
266
281
)
282
+ docker_desktop_kube_running = ToolInfo (
283
+ tool_name = "Kubernetes Running in Docker Desktop" ,
284
+ is_installed_func = is_docker_desktop_kube_running ,
285
+ install_instruction = "Please enable the local kubernetes cluster in Docker Desktop" ,
286
+ install_url = "https://docs.docker.com/desktop/kubernetes/" ,
287
+ )
267
288
minikube_running_info = ToolInfo (
268
289
tool_name = "Running Minikube" ,
269
290
is_installed_func = is_minikube_running ,
@@ -319,19 +340,20 @@ def check_installation(tool_info: ToolInfo) -> ToolStatus:
319
340
320
341
check_results : list [ToolStatus ] = []
321
342
if answers :
343
+ check_results .append (check_installation (kubectl_info ))
344
+ check_results .append (check_installation (helm_info ))
322
345
if answers ["platform" ] == "Docker Desktop" :
323
346
check_results .append (check_installation (docker_info ))
324
347
check_results .append (check_installation (docker_desktop_info ))
325
348
check_results .append (check_installation (docker_running_info ))
349
+ check_results .append (check_installation (docker_desktop_kube_running ))
326
350
elif answers ["platform" ] == "Minikube" :
327
351
check_results .append (check_installation (docker_info ))
328
352
check_results .append (check_installation (docker_running_info ))
329
353
check_results .append (check_installation (minikube_info ))
330
354
if is_platform_darwin ():
331
355
check_results .append (check_installation (minikube_version_info ))
332
356
check_results .append (check_installation (minikube_running_info ))
333
- check_results .append (check_installation (kubectl_info ))
334
- check_results .append (check_installation (helm_info ))
335
357
else :
336
358
click .secho ("Please re-run setup." , fg = "yellow" )
337
359
sys .exit (1 )
0 commit comments