@@ -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 ,
@@ -211,6 +237,7 @@ def generate_appwrapper(
211
237
instascale : bool ,
212
238
instance_types : list ,
213
239
env ,
240
+ priority : str ,
214
241
):
215
242
user_yaml = read_template (template )
216
243
appwrapper_name , cluster_name = gen_names (name )
@@ -219,6 +246,8 @@ def generate_appwrapper(
219
246
route_item = resources ["resources" ].get ("GenericItems" )[1 ]
220
247
update_names (user_yaml , item , appwrapper_name , cluster_name , namespace )
221
248
update_labels (user_yaml , instascale , instance_types )
249
+ update_priority (user_yaml , item , priority )
250
+ update_scheduling_spec (user_yaml , workers )
222
251
update_custompodresources (
223
252
item , min_cpu , max_cpu , min_memory , max_memory , gpu , workers
224
253
)
@@ -315,6 +344,12 @@ def main(): # pragma: no cover
315
344
default = "default" ,
316
345
help = "Set the kubernetes namespace you want to deploy your cluster to. Default. If left blank, uses the 'default' namespace" ,
317
346
)
347
+ parser .add_argument (
348
+ "--priority" ,
349
+ required = False ,
350
+ default = "low" ,
351
+ help = "Set the priority of the cluster. Default is 'low'. Options are 'low', 'default', 'high'" ,
352
+ )
318
353
319
354
args = parser .parse_args ()
320
355
name = args .name
@@ -329,6 +364,7 @@ def main(): # pragma: no cover
329
364
instascale = args .instascale
330
365
instance_types = args .instance_types
331
366
namespace = args .namespace
367
+ priority = args .priority
332
368
env = {}
333
369
334
370
outfile = generate_appwrapper (
@@ -345,6 +381,7 @@ def main(): # pragma: no cover
345
381
instascale ,
346
382
instance_types ,
347
383
env ,
384
+ priority ,
348
385
)
349
386
return outfile
350
387
0 commit comments