23
23
install_nccl_on_cluster ,
24
24
set_jobset_on_cluster ,
25
25
setup_k8s_env ,
26
+ update_cluster_with_gcpfilestore_driver_if_necessary ,
26
27
update_cluster_with_gcsfuse_driver_if_necessary ,
27
28
update_cluster_with_workload_identity_if_necessary ,
28
29
)
29
30
from ..core .cluster_private import authorize_private_cluster_access_if_necessary
30
31
from ..core .commands import run_command_for_value , run_command_with_updates
31
32
from ..core .config import VERTEX_TENSORBOARD_FEATURE_FLAG
32
- from ..core .gcloud_context import (
33
- add_zone_and_project ,
34
- get_gke_control_plane_version ,
35
- get_gke_server_config ,
36
- zone_to_region ,
37
- )
33
+ from ..core .gcloud .context import GCloudContextManager , GKEVersionManager
38
34
from ..core .kjob import apply_kjob_crds , prepare_kjob , verify_kjob_installed
39
35
from ..core .kueue import (
40
36
cluster_preheat_yml ,
64
60
from ..utils .file import write_tmp_file
65
61
from . import cluster_gcluster
66
62
from .common import set_cluster_command
67
- from ..core .cluster import update_cluster_with_gcpfilestore_driver_if_necessary
68
63
69
64
70
65
def cluster_create (args ) -> None :
@@ -83,7 +78,7 @@ def cluster_create(args) -> None:
83
78
xpk_exit (return_code )
84
79
85
80
xpk_print (f'Starting cluster create for cluster { args .cluster } :' , flush = True )
86
- add_zone_and_project (args )
81
+ GCloudContextManager . add_zone_and_project (args )
87
82
88
83
if system .device_type in cluster_gcluster .supported_device_types :
89
84
xpk_print (
@@ -93,12 +88,10 @@ def cluster_create(args) -> None:
93
88
cluster_gcluster .cluster_create (args )
94
89
xpk_exit (0 )
95
90
96
- return_code , gke_server_config = get_gke_server_config (args )
97
- if return_code != 0 :
98
- xpk_exit (return_code )
91
+ gke_server_config = GKEVersionManager (args )
99
92
100
- return_code , gke_control_plane_version = get_gke_control_plane_version (
101
- args , gke_server_config
93
+ return_code , gke_control_plane_version = (
94
+ gke_server_config . get_gke_control_plane_version ()
102
95
)
103
96
if return_code != 0 :
104
97
xpk_exit (return_code )
@@ -257,7 +250,7 @@ def cluster_create(args) -> None:
257
250
xpk_print (
258
251
'See your GKE Cluster here:'
259
252
# pylint: disable=line-too-long
260
- f' https://console.cloud.google.com/kubernetes/clusters/details/{ zone_to_region (args .zone )} /{ args .cluster } /details?project={ args .project } '
253
+ f' https://console.cloud.google.com/kubernetes/clusters/details/{ GCloudContextManager . zone_to_region (args .zone )} /{ args .cluster } /details?project={ args .project } '
261
254
)
262
255
xpk_exit (0 )
263
256
@@ -272,7 +265,7 @@ def cluster_delete(args) -> None:
272
265
0 if successful and 1 otherwise.
273
266
"""
274
267
xpk_print (f'Starting cluster delete for cluster: { args .cluster } ' , flush = True )
275
- add_zone_and_project (args )
268
+ GCloudContextManager . add_zone_and_project (args )
276
269
277
270
if cluster_gcluster .created_by_gcluster (args ):
278
271
xpk_print (f'Deleting { args .cluster } cluster using Cluster Toolkit...' )
@@ -303,7 +296,7 @@ def cluster_cacheimage(args) -> None:
303
296
xpk_print (
304
297
f'Starting cluster cacheimage for cluster: { args .cluster } ' , flush = True
305
298
)
306
- add_zone_and_project (args )
299
+ GCloudContextManager . add_zone_and_project (args )
307
300
308
301
get_cluster_credentials (args )
309
302
system , return_code = get_system_characteristics (args )
@@ -352,7 +345,7 @@ def cluster_describe(args) -> None:
352
345
0 if successful and 1 otherwise.
353
346
"""
354
347
xpk_print (f'Starting nodepool list for cluster: { args .cluster } ' , flush = True )
355
- add_zone_and_project (args )
348
+ GCloudContextManager . add_zone_and_project (args )
356
349
357
350
get_cluster_credentials (args )
358
351
@@ -583,7 +576,7 @@ def cluster_list(args) -> None:
583
576
Returns:
584
577
0 if successful and 1 otherwise.
585
578
"""
586
- add_zone_and_project (args )
579
+ GCloudContextManager . add_zone_and_project (args )
587
580
xpk_print (f'For project { args .project } and zone { args .zone } :' , flush = True )
588
581
if run_gke_clusters_list_command (args ):
589
582
xpk_exit (1 )
@@ -675,7 +668,7 @@ def run_gke_cluster_delete_command(args) -> int:
675
668
command = (
676
669
'gcloud beta container clusters delete'
677
670
f' { args .cluster } --project={ args .project } '
678
- f' --region={ zone_to_region (args .zone )} --quiet'
671
+ f' --region={ GCloudContextManager . zone_to_region (args .zone )} --quiet'
679
672
)
680
673
681
674
return_code = run_command_with_updates (command , 'Cluster Delete' , args )
@@ -701,7 +694,7 @@ def run_gke_clusters_list_command(args) -> int:
701
694
"""
702
695
command = (
703
696
'gcloud container clusters list'
704
- f' --project={ args .project } --region={ zone_to_region (args .zone )} '
697
+ f' --project={ args .project } --region={ GCloudContextManager . zone_to_region (args .zone )} '
705
698
)
706
699
return_code = run_command_with_updates (command , 'Cluster List' , args )
707
700
if return_code != 0 :
@@ -748,7 +741,7 @@ def run_gke_cluster_create_command(
748
741
command = (
749
742
'gcloud beta container clusters create'
750
743
f' { args .cluster } --project={ args .project } '
751
- f' --region={ zone_to_region (args .zone )} '
744
+ f' --region={ GCloudContextManager . zone_to_region (args .zone )} '
752
745
f' --node-locations={ args .zone } '
753
746
f' --cluster-version={ gke_control_plane_version } '
754
747
f' --machine-type={ machine_type } '
0 commit comments