@@ -18,21 +18,15 @@ def upgrade_helm_chart(cluster_name, region, helm_deploy_dir, hub_deploy_dir):
1818def __upgrade_or_install_helm_chart (
1919 cluster_name , region , helm_deploy_dir , hub_deploy_dir , upgrade = False
2020):
21- install_template_fp = os .path .join (STRUCTURE ["templates" ]["helm" ], "install .yaml" )
22- install_deploy_fp = os .path .join (helm_deploy_dir , "install .yaml" )
21+ chart_template_fp = os .path .join (STRUCTURE ["templates" ]["helm" ], "chart .yaml" )
22+ chart_deploy_fp = os .path .join (helm_deploy_dir , "chart .yaml" )
2323
2424 placeholder_replacements = dict (REGION = region )
25- fill_file_placeholders (
26- install_template_fp , install_deploy_fp , placeholder_replacements
27- )
28-
29- helm = read_yaml (install_deploy_fp )
25+ fill_file_placeholders (chart_template_fp , chart_deploy_fp , placeholder_replacements )
3026
31- chart_release = helm ["release" ]
32- cluster_namespace = helm ["namespace" ]
33- region = helm ["region" ]
34-
35- helm_chart = os .path .join (helm_deploy_dir , "helm-chart" )
27+ helm_config = read_yaml (chart_deploy_fp )
28+ repo_config = helm_config ["repo" ]
29+ install_config = helm_config ["install" ]
3630
3731 config_file = os .path .join (hub_deploy_dir , "config.yaml" )
3832
@@ -43,40 +37,34 @@ def __upgrade_or_install_helm_chart(
4337 "container" ,
4438 "clusters" ,
4539 "get-credentials" ,
46- f"--location={ region } " ,
40+ f"--location={ install_config [ ' region' ] } " ,
4741 cluster_name ,
4842 ]
4943 )
5044
51- if upgrade :
52- cmds .append (
53- [
54- "helm" ,
55- "upgrade" ,
56- "--cleanup-on-fail" ,
57- chart_release ,
58- helm_chart ,
59- "--namespace" ,
60- cluster_namespace ,
61- "--values" ,
62- config_file ,
63- ]
64- )
65- else :
66- cmds .append (
67- [
68- "helm" ,
69- "upgrade" ,
70- "--cleanup-on-fail" ,
71- "--install" ,
72- chart_release ,
73- helm_chart ,
74- "--namespace" ,
75- cluster_namespace ,
76- "--values" ,
77- config_file ,
78- ]
79- )
45+ # Add and update Helm repo
46+ cmds .append (["helm" , "repo" , "add" , repo_config ["repo_name" ], repo_config ["url" ]])
47+ cmds .append (["helm" , "repo" , "update" ])
48+
49+ # Main helm command
50+ helm_command = [
51+ "helm" ,
52+ "upgrade" ,
53+ "--cleanup-on-fail" ,
54+ ]
55+ if not upgrade :
56+ helm_command .append ("--install" )
57+ helm_command += [
58+ install_config ["release" ],
59+ f"{ repo_config ['repo_name' ]} /{ install_config ['chart_name' ]} " ,
60+ "--namespace" ,
61+ install_config ["namespace" ],
62+ "--version" ,
63+ install_config ["chart_version" ],
64+ "--values" ,
65+ config_file ,
66+ ]
67+ cmds .append (helm_command )
8068
8169 for cmd in cmds :
8270 run_cmd (cmd )
0 commit comments