29
29
"prod" : "us-central1" ,
30
30
}
31
31
32
+ AWS_DEPLOYMENTS = {"aws-curvenote" : "binderhub" }
33
+
32
34
# Mapping of cluster names (keys) to resource group names (values) for Azure deployments
33
35
AZURE_RGs = {}
34
36
@@ -41,7 +43,7 @@ def check_call(*args):
41
43
Print a command if DRY_RUN is true, otherwise run it with subprocess.check_call
42
44
"""
43
45
if DRY_RUN :
44
- print ("dry-run: " .join (* args ))
46
+ print ("dry-run:" , " " .join (* args ))
45
47
else :
46
48
subprocess .check_call (* args )
47
49
@@ -51,7 +53,8 @@ def check_output(*args):
51
53
Print a command if DRY_RUN is true, otherwise run it with subprocess.check_output
52
54
"""
53
55
if DRY_RUN :
54
- print ("dry-run: " .join (* args ))
56
+ print ("dry-run:" , " " .join (* args ))
57
+ return b""
55
58
else :
56
59
return subprocess .check_output (* args )
57
60
@@ -138,6 +141,27 @@ def setup_auth_gcloud(release, cluster=None):
138
141
)
139
142
140
143
144
+ def setup_auth_aws (cluster ):
145
+ """
146
+ Set up authentication for EKS on AWS
147
+
148
+ Assumes you already have an AWS CLI profile setup with access to EKS,
149
+ and that either this is the default profile (e.g. on CI) or you have set the
150
+ AWS_PROFILE environment variable.
151
+ """
152
+ print (f"Obtaining AWS EKS kubeconfig for { cluster } " )
153
+
154
+ eks_kubeconfig = [
155
+ "aws" ,
156
+ "eks" ,
157
+ "update-kubeconfig" ,
158
+ "--name" ,
159
+ AWS_DEPLOYMENTS [cluster ],
160
+ ]
161
+ stdout = check_output (eks_kubeconfig )
162
+ print (stdout .decode ("utf8" ))
163
+
164
+
141
165
def update_networkbans (cluster ):
142
166
"""
143
167
Run secrets/ban.py to update network bans
@@ -163,7 +187,9 @@ def get_config_files(release, config_dir="config"):
163
187
)
164
188
# release-specific config files
165
189
for config_dir in (config_dir , os .path .join ("secrets" , config_dir )):
166
- config_files .append (os .path .join (config_dir , release + ".yaml" ))
190
+ f = os .path .join (config_dir , release + ".yaml" )
191
+ if os .path .exists (f ):
192
+ config_files .append (f )
167
193
return config_files
168
194
169
195
@@ -303,6 +329,41 @@ def patch_coredns():
303
329
)
304
330
305
331
332
+ def deploy_kube_system_charts (release , name = None ):
333
+ """
334
+ Some charts must be deployed into the kube-system namespace
335
+ """
336
+ if not name :
337
+ name = release
338
+ log_name = f"mybinder-kube-system { release } "
339
+
340
+ config_files = get_config_files (release , config_dir = "config-kube-system" )
341
+ if not config_files :
342
+ print (BOLD + GREEN + f"No config files found for { log_name } " + NC , flush = True )
343
+ return
344
+
345
+ print (BOLD + GREEN + f"Starting helm upgrade for { log_name } " + NC , flush = True )
346
+ helm = [
347
+ "helm" ,
348
+ "upgrade" ,
349
+ "--install" ,
350
+ "--cleanup-on-fail" ,
351
+ "--namespace=kube-system" ,
352
+ name ,
353
+ "mybinder-kube-system" ,
354
+ ]
355
+ for config_file in config_files :
356
+ helm .extend (["-f" , config_file ])
357
+
358
+ check_call (helm )
359
+ print (
360
+ BOLD + GREEN + f"SUCCESS: Helm upgrade for { log_name } completed" + NC ,
361
+ flush = True ,
362
+ )
363
+
364
+ wait_for_deployments_daemonsets ("kube-system" )
365
+
366
+
306
367
def main ():
307
368
# parse command line args
308
369
argparser = argparse .ArgumentParser ()
@@ -314,6 +375,7 @@ def main():
314
375
"prod" ,
315
376
"ovh" ,
316
377
"ovh2" ,
378
+ "aws-curvenote" ,
317
379
],
318
380
)
319
381
argparser .add_argument (
@@ -372,10 +434,13 @@ def main():
372
434
setup_auth_azure (cluster )
373
435
elif cluster in GCP_PROJECTS :
374
436
setup_auth_gcloud (args .release , cluster )
437
+ elif cluster in AWS_DEPLOYMENTS :
438
+ setup_auth_aws (cluster )
375
439
else :
376
440
raise Exception ("Cloud cluster not recognised!" )
377
441
378
442
update_networkbans (cluster )
443
+ deploy_kube_system_charts (args .release , args .name )
379
444
deploy (args .release , args .name )
380
445
381
446
0 commit comments