nephos icon indicating copy to clipboard operation
nephos copied to clipboard

Investigate the use of PyHelm to replace the execution of helm via subprocess.

Open dbandin opened this issue 5 years ago • 2 comments

Investigate the library PyHelm to replace the "helm" commands launched from Python using subprocess.

  • Could be cleaner to handle credentials to access helm in the cluster.
  • Maybe we can reduce the complexity of unit-testing using this library.
  • Adding the third party library we may reduce the maintenance load, make the code more clear to handle using only python code and not having to assemble cli commands, and what is expected from the api call could be more reliable.
  • Reduce the error handling special characters and how we are escaping them.

Module documentation: https://pypi.org/project/pyhelm/

Example of how we execute:

  • We create a command string:
command = "helm install {repo}/{app} -n {name} --namespace {ns}".format(
  • Execute method:
  if show_command:
       print(t.magenta(command))
   try:
       # TODO: Can we do this with a different command than check_output (Bandit security issue)
       result = check_output(command, stderr=STDOUT, shell=True)
       decoded = result.decode("utf-8")
       if verbose:
           print(decoded)
       return decoded, None
   except CalledProcessError as e:
       error_text = e.output.decode("utf-8")
       if show_errors:
           print(t.red("Command failed with CalledProcessError:"))
           print(error_text)
return None, error_text

This could help to fix https://github.com/hyperledger-labs/nephos/issues/26

dbandin avatar Jun 12 '19 15:06 dbandin

Aha, PyHelm appears to be relatively young project. I agree that it is worth looking into it, and agree that getting rid of as many subprocess calls as possible, would be helpful.

And anything that reduces the Unit Test complexity without sacrificing functionality is worthwhile.

alexvicegrab avatar Jun 13 '19 15:06 alexvicegrab

Related tools mentioned on Helm website include:

https://github.com/reactiveops/reckoner

Furthermore, currently we use Helm, but depending on the future of Kubernetes packaging, we may also consider using https://github.com/kubernetes-sigs/kustomize

alexvicegrab avatar Jun 13 '19 15:06 alexvicegrab