if not await self._namespace_exists(cluster_id, namespace):
err_msg = (
"namespace {} does not exist in cluster_id {} "
- "error message: ".format(
- namespace, e
- )
+ "error message: ".format(namespace, e)
)
self.log.error(err_msg)
raise K8sException(err_msg)
return _rc
- async def _get_services(self, cluster_id: str, kdu_instance: str, namespace: str):
+ async def _get_services(
+ self, cluster_id: str, kdu_instance: str, namespace: str, kubeconfig: str
+ ):
# init config, env
paths, env = self._init_paths_env(
cluster_name=cluster_id, create_if_not_exist=True
)
- command1 = "{} get manifest {} --namespace={}".format(
- self._helm_command, kdu_instance, namespace
+ command1 = "env KUBECONFIG={} {} get manifest {} --namespace={}".format(
+ kubeconfig, self._helm_command, kdu_instance, namespace
)
command2 = "{} get --namespace={} -f -".format(self.kubectl_command, namespace)
output, _rc = await self._local_async_exec_pipe(
paths, env = self._init_paths_env(
cluster_name=cluster_id, create_if_not_exist=True
)
- command = "{} status {} --namespace={} --output yaml".format(
- self._helm_command, kdu_instance, namespace
+ command = "env KUBECONFIG={} {} status {} --namespace={} --output yaml".format(
+ paths["kube_config"], self._helm_command, kdu_instance, namespace
)
output, rc = await self._local_async_exec(
version: str,
atomic: bool,
timeout: float,
+ kubeconfig: str,
) -> str:
timeout_str = ""
version_str = "--version {}".format(version)
command = (
- "{helm} install {name} {atomic} --output yaml "
+ "env KUBECONFIG={kubeconfig} {helm} install {name} {atomic} --output yaml "
"{params} {timeout} {ns} {model} {ver}".format(
+ kubeconfig=kubeconfig,
helm=self._helm_command,
name=kdu_instance,
atomic=atomic_str,
version: str,
atomic: bool,
timeout: float,
+ kubeconfig: str,
) -> str:
timeout_str = ""
namespace_str = "--namespace {}".format(namespace)
command = (
- "{helm} upgrade {name} {model} {namespace} {atomic} --output yaml {params} "
- "{timeout} {ver}".format(
- helm=self._helm_command,
- name=kdu_instance,
- namespace=namespace_str,
- atomic=atomic_str,
- params=params_str,
- timeout=timeout_str,
- model=kdu_model,
- ver=version_str,
- )
+ "env KUBECONFIG={kubeconfig} {helm} upgrade {name} {model} {namespace} {atomic} "
+ "--output yaml {params} {timeout} {ver}"
+ ).format(
+ kubeconfig=kubeconfig,
+ helm=self._helm_command,
+ name=kdu_instance,
+ namespace=namespace_str,
+ atomic=atomic_str,
+ params=params_str,
+ timeout=timeout_str,
+ model=kdu_model,
+ ver=version_str,
)
return command
def _get_rollback_command(
- self, kdu_instance: str, namespace: str, revision: float
+ self, kdu_instance: str, namespace: str, revision: float, kubeconfig: str
) -> str:
- return "{} rollback {} {} --namespace={} --wait".format(
- self._helm_command, kdu_instance, revision, namespace
+ return "env KUBECONFIG={} {} rollback {} {} --namespace={} --wait".format(
+ kubeconfig, self._helm_command, kdu_instance, revision, namespace
)
- def _get_uninstall_command(self, kdu_instance: str, namespace: str) -> str:
+ def _get_uninstall_command(
+ self, kdu_instance: str, namespace: str, kubeconfig: str
+ ) -> str:
- return "{} uninstall {} --namespace={}".format(
- self._helm_command, kdu_instance, namespace
+ return "env KUBECONFIG={} {} uninstall {} --namespace={}".format(
+ kubeconfig, self._helm_command, kdu_instance, namespace
)
def _get_helm_chart_repos_ids(self, cluster_uuid) -> list: