Feature 10956: Add namespace and force arguments to helm upgrade
Change-Id: I8e37e43b72c5f7f63c4b9f49542905727610fa5a
Signed-off-by: Gabriel Cuba <gcuba@whitestack.com>
diff --git a/n2vc/k8s_helm_conn.py b/n2vc/k8s_helm_conn.py
index cd440a9..0ea8920 100644
--- a/n2vc/k8s_helm_conn.py
+++ b/n2vc/k8s_helm_conn.py
@@ -702,6 +702,7 @@
atomic,
timeout,
kubeconfig,
+ force: bool = False,
) -> str:
"""Generates the command to upgrade a Helm Chart release
@@ -715,7 +716,7 @@
The --wait flag will be set automatically if --atomic is used
timeout (float): The time, in seconds, to wait
kubeconfig (str): Kubeconfig file path
-
+ force (bool): If set, helm forces resource updates through a replacement strategy. This may recreate pods.
Returns:
str: command to upgrade a Helm Chart release
"""
@@ -729,18 +730,30 @@
if atomic:
atomic_str = "--atomic"
+ # force
+ force_str = ""
+ if force:
+ force_str = "--force "
+
# version
version_str = ""
if version:
version_str = "--version {}".format(version)
+ # namespace
+ namespace_str = ""
+ if namespace:
+ namespace_str = "--namespace {}".format(namespace)
+
command = (
- "env KUBECONFIG={kubeconfig} {helm} upgrade {atomic} --output yaml {params} {timeout} "
+ "env KUBECONFIG={kubeconfig} {helm} upgrade {namespace} {atomic} --output yaml {params} {timeout} {force}"
"--reuse-values {name} {model} {ver}"
).format(
kubeconfig=kubeconfig,
helm=self._helm_command,
+ namespace=namespace_str,
atomic=atomic_str,
+ force=force_str,
params=params_str,
timeout=timeout_str,
name=kdu_instance,