Skip to content

Commit f3776f7

Browse files
committed
install helm if it's not installed already
1 parent eacc204 commit f3776f7

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

smol-k8s-lab.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ def configure_external_secrets(external_secrets_config):
221221
'stringData': {'token': gitlab_access_token}}
222222

223223
install_custom_resource(gitlab_secret)
224+
return
224225

225226

226227
def delete_cluster(k8s_distro="k3s"):
@@ -233,8 +234,25 @@ def delete_cluster(k8s_distro="k3s"):
233234
subproc(['k3s-uninstall.sh'])
234235
elif k8s_distro == 'kind':
235236
subproc(['kind delete cluster'])
236-
elif k8s_distro == 'k0s':
237-
header("┌(・Σ・)┘≡З Whoops. k0s not YET supported.")
237+
else:
238+
header("┌(・Σ・)┘≡З Whoops. {k8s_distro} not YET supported.")
239+
return
240+
241+
242+
def get_helm_ready(k8s_distro="", argo=False):
243+
"""
244+
get helm installed if needed, and then install/update all the helm repos
245+
"""
246+
header("Adding/Updating helm repos...")
247+
if not shutil.which("helm"):
248+
msg = ("ʕ•́ᴥ•̀ʔ [bold]Helm[/bold] is [warn]not installed[/warn]. "
249+
"[i]We'll install it for you.[/i] ʕᵔᴥᵔʔ")
250+
CONSOLE.print(msg, justify='center')
251+
subproc(['brew install helm'])
252+
253+
# this is where we add all the helm repos we're going to use
254+
add_default_repos(k8s_distro, argo)
255+
return
238256

239257

240258
k9_help = 'Run k9s as soon as this script is complete. Defaults to False'
@@ -311,11 +329,10 @@ def main(k8s: str,
311329
print('')
312330
install_k8s_distro(k8s)
313331

314-
# this is where we add all the helm repos we're going to use
315-
header("Adding/Updating helm repos...")
316-
add_default_repos(k8s, argo)
332+
# make sure helm is installed and the repos are up to date
333+
get_helm_ready(k8s, argo)
317334

318-
# needed for metal installs
335+
# needed for metal (non-cloud provider) installs
319336
header("Configuring metallb so we have an ip address pool")
320337
configure_metallb(input_variables['address_pool'])
321338

0 commit comments

Comments
 (0)