Allow to provide custom kubectl config
Allows to connect to any cluster, not just local one.
Change-Id: I75f17ac26a72d7f9ef555e53d3bbe6a08beec15d
diff --git a/_modules/helm.py b/_modules/helm.py
index 80632d1..a71c53c 100644
--- a/_modules/helm.py
+++ b/_modules/helm.py
@@ -20,25 +20,32 @@
tiller_args = ('--host', tiller_kwargs['tiller_host'])
else:
tiller_args = ('--tiller-namespace', tiller_kwargs['tiller_namespace'])
+ env = {'HELM_HOME': HELM_HOME}
+ if tiller_kwargs['kube_config']:
+ env['KUBECONFIG'] = tiller_kwargs['kube_config']
return {
'cmd': ('helm',) + tiller_args + args,
- 'env': {'HELM_HOME': HELM_HOME},
+ 'env': env,
}
def release_exists(name, namespace='default',
- tiller_namespace='kube-system', tiller_host=None):
+ tiller_namespace='kube-system', tiller_host=None,
+ kube_config=None):
cmd = _helm_cmd('list', '--short', '--all', '--namespace', namespace, name,
- tiller_namespace=tiller_namespace, tiller_host=tiller_host)
+ tiller_namespace=tiller_namespace, tiller_host=tiller_host,
+ kube_config=kube_config)
return __salt__['cmd.run_stdout'](**cmd) == name
def release_create(name, chart_name, namespace='default',
version=None, values=None,
- tiller_namespace='kube-system', tiller_host=None):
+ tiller_namespace='kube-system', tiller_host=None,
+ kube_config=None):
tiller_args = {
'tiller_namespace': tiller_namespace,
'tiller_host': tiller_host,
+ 'kube_config': kube_config,
}
args = []
if version is not None:
@@ -53,18 +60,22 @@
return ok_or_output(cmd, 'Failed to create release "{}"'.format(name))
-def release_delete(name, tiller_namespace='kube-system', tiller_host=None):
+def release_delete(name, tiller_namespace='kube-system', tiller_host=None,
+ kube_config=None):
cmd = _helm_cmd('delete', '--purge', name,
- tiller_namespace=tiller_namespace, tiller_host=tiller_host)
+ tiller_namespace=tiller_namespace, tiller_host=tiller_host,
+ kube_config=kube_config)
return ok_or_output(cmd, 'Failed to delete release "{}"'.format(name))
def release_upgrade(name, chart_name, namespace='default',
version=None, values=None,
- tiller_namespace='kube-system', tiller_host=None):
+ tiller_namespace='kube-system', tiller_host=None,
+ kube_config=None):
tiller_args = {
'tiller_namespace': tiller_namespace,
'tiller_host': tiller_host,
+ 'kube_config': kube_config,
}
args = []
if version is not None:
@@ -79,7 +90,9 @@
return ok_or_output(cmd, 'Failed to upgrade release "{}"'.format(name))
-def get_values(name, tiller_namespace='kube-system', tiller_host=None):
+def get_values(name, tiller_namespace='kube-system', tiller_host=None,
+ kube_config=None):
cmd = _helm_cmd('get', 'values', '--all', name,
- tiller_namespace=tiller_namespace, tiller_host=tiller_host)
+ tiller_namespace=tiller_namespace, tiller_host=tiller_host,
+ kube_config=kube_config)
return yaml.deserialize(__salt__['cmd.run_stdout'](**cmd))