@@ -76,6 +76,27 @@ def update_labels(yaml, instascale, instance_types):
76
76
metadata .pop ("labels" )
77
77
78
78
79
+ def update_priority (yaml , item , priority ):
80
+ if priority not in ["low" , "default" , "high" ]:
81
+ sys .exit ("Priority must be 'low', 'default', or 'high'" )
82
+
83
+ priority_levels = {
84
+ "low" : (1 , "low-priority" ),
85
+ "default" : (5 , "default-priority" ),
86
+ "high" : (10 , "high-priority" ),
87
+ }
88
+
89
+ priority_level = priority_levels [priority ]
90
+ spec = yaml .get ("spec" )
91
+ spec ["priority" ] = priority_level [0 ]
92
+ # spec["SchedulingSpec"]["priorityClassName"] = priority_level
93
+ if "generictemplate" in item .keys ():
94
+ head = item .get ("generictemplate" ).get ("spec" ).get ("headGroupSpec" )
95
+ worker = item .get ("generictemplate" ).get ("spec" ).get ("workerGroupSpecs" )[0 ]
96
+ head ["template" ]["spec" ]["priorityClassName" ] = priority_level [1 ]
97
+ worker ["template" ]["spec" ]["priorityClassName" ] = priority_level [1 ]
98
+
99
+
79
100
def update_custompodresources (
80
101
item , min_cpu , max_cpu , min_memory , max_memory , gpu , workers
81
102
):
@@ -155,6 +176,11 @@ def update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, gpu):
155
176
limits ["nvidia.com/gpu" ] = gpu
156
177
157
178
179
+ def update_scheduling_spec (yaml , workers ):
180
+ spec = yaml .get ("spec" )
181
+ spec ["schedulingSpec" ]["minAvailable" ] = workers + 1
182
+
183
+
158
184
def update_nodes (
159
185
item ,
160
186
appwrapper_name ,
@@ -210,6 +236,7 @@ def generate_appwrapper(
210
236
instascale : bool ,
211
237
instance_types : list ,
212
238
env ,
239
+ priority : str ,
213
240
):
214
241
user_yaml = read_template (template )
215
242
appwrapper_name , cluster_name = gen_names (name )
@@ -218,6 +245,8 @@ def generate_appwrapper(
218
245
route_item = resources ["resources" ].get ("GenericItems" )[1 ]
219
246
update_names (user_yaml , item , appwrapper_name , cluster_name , namespace )
220
247
update_labels (user_yaml , instascale , instance_types )
248
+ update_priority (user_yaml , item , priority )
249
+ update_scheduling_spec (user_yaml , workers )
221
250
update_custompodresources (
222
251
item , min_cpu , max_cpu , min_memory , max_memory , gpu , workers
223
252
)
@@ -314,6 +343,12 @@ def main(): # pragma: no cover
314
343
default = "default" ,
315
344
help = "Set the kubernetes namespace you want to deploy your cluster to. Default. If left blank, uses the 'default' namespace" ,
316
345
)
346
+ parser .add_argument (
347
+ "--priority" ,
348
+ required = False ,
349
+ default = "low" ,
350
+ help = "Set the priority of the cluster. Default is 'low'. Options are 'low', 'default', 'high'" ,
351
+ )
317
352
318
353
args = parser .parse_args ()
319
354
name = args .name
@@ -328,6 +363,7 @@ def main(): # pragma: no cover
328
363
instascale = args .instascale
329
364
instance_types = args .instance_types
330
365
namespace = args .namespace
366
+ priority = args .priority
331
367
env = {}
332
368
333
369
outfile = generate_appwrapper (
@@ -344,6 +380,7 @@ def main(): # pragma: no cover
344
380
instascale ,
345
381
instance_types ,
346
382
env ,
383
+ priority ,
347
384
)
348
385
return outfile
349
386
0 commit comments