New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm module feedback #29661

Open
bryanlarsen opened this Issue Sep 11, 2017 · 15 comments

Comments

Projects
None yet
8 participants
@bryanlarsen
Contributor

bryanlarsen commented Sep 11, 2017

ISSUE TYPE
  • Documentation Report
COMPONENT NAME

helm

ANSIBLE VERSION
v2.4.0.0-0.1.rc1
python version = 2.7.12
SUMMARY

I tried out the helm module from the 2.4 prerelease. Here's my feedback.

  • The possible values for chart.source.type are not listed. I looked into the source code and found that currently only git and repo are supported. I created a PR at flaper87/pyhelm#2 to also support a chart.source.type of directory.

  • I expected this module to be able to determine the tiller's hostname and port automatically. For consistency this module should support the same authentication parameters as the kubernetes module, as well as the service name & namespace (default tiller-deploy & kube-system).

Frankly, that's a bit of a PITA, the kubernetes module should support specifying a kubeconfig file or remote location, and so should this module.

An easier option would be just to add to the documentation what I did as an example:

- command: "kubectl get svc -n kube-system tiller-deploy -o jsonpath='{.spec.clusterIP}'"
  register: tiller_host

- helm:
    host: "{{ tiller_host.stdout }}"
    ....

CC: @flaper87

@wknapik

This comment has been minimized.

Contributor

wknapik commented Nov 3, 2017

Also, the helm module locks the user into python2, due to pyhelm depending on grpc, which is python2-only.

@flaper87

This comment has been minimized.

Contributor

flaper87 commented Nov 9, 2017

Hey folks,

Thanks a lot for the feedback, just wanted to let you know that I'll look into this soon. Sorry it's taken me long but I missed the notification when it was created and I'm now out in a business trip.

Thanks again :)

@wknapik

This comment has been minimized.

Contributor

wknapik commented Nov 14, 2017

@flaper87 - please take a look at the remaining helm module issues. The inability to upgrade (#32545) and install dependencies (#32911) are blockers for end users. The former is nearly two weeks old, with a PR attached to it and no feedback at all so far.

@pjanuario

This comment has been minimized.

pjanuario commented Jan 22, 2018

Just crossed the issue right now, can use the module since I am using python 3... :/

@flaper87

This comment has been minimized.

Contributor

flaper87 commented Jan 22, 2018

I've removed the dependency on grpc now. flaper87/pyhelm#7

@pjanuario do you want to give pyhelm master a try? That'd be helpful before the release.

@pjanuario

This comment has been minimized.

pjanuario commented Jan 22, 2018

@flaper87 yes, I can do it right now, but I am bit noob with python, pip and eggs.. 🙃 Any instructions on how I can use the master directly would be helpful.... anyway i will try to find it now.

@pjanuario

This comment has been minimized.

pjanuario commented Jan 22, 2018

@flaper87 I might be doing something wrong but I tried the following and didnt work:

/usr/bin/pip3 install git+https://github.com/flaper87/pyhelm.git#egg=pyhelm
Collecting pyhelm from git+https://github.com/flaper87/pyhelm.git#egg=pyhelm
  Cloning https://github.com/flaper87/pyhelm.git to /tmp/pip-build-6f6bmdrf/pyhelm
Collecting grpcio==1.1.3 (from pyhelm)
  Using cached grpcio-1.1.3-cp35-cp35m-manylinux1_x86_64.whl
Collecting grpcio-tools==1.1.3 (from pyhelm)
  Using cached grpcio_tools-1.1.3-cp35-cp35m-manylinux1_x86_64.whl
Collecting protobuf==3.2.0 (from pyhelm)
  Using cached protobuf-3.2.0-cp35-cp35m-manylinux1_x86_64.whl
Collecting supermutes==0.2.5 (from pyhelm)
  Using cached supermutes-0.2.5.tar.gz
Collecting pygit2>=0.24.2 (from pyhelm)
  Using cached pygit2-0.26.3.tar.gz
    Complete output from command python setup.py egg_info:
    c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
    compilation terminated.
    Traceback (most recent call last):
      File "/usr/lib/python3.5/distutils/unixccompiler.py", line 118, in _compile
        extra_postargs)
      File "/usr/lib/python3.5/distutils/ccompiler.py", line 909, in spawn
        spawn(cmd, dry_run=self.dry_run)
      File "/usr/lib/python3.5/distutils/spawn.py", line 36, in spawn
        _spawn_posix(cmd, search_path, dry_run=dry_run)
      File "/usr/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
        % (cmd, exit_status))
    distutils.errors.DistutilsExecError: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 161, in run
        cmd = self.call_command('install_lib', warn_dir=0)
      File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 147, in call_command
        self.run_command(cmdname)
      File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/install_lib.py", line 23, in run
        self.build()
      File "/usr/lib/python3.5/distutils/command/install_lib.py", line 109, in build
        self.run_command('build_ext')
      File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 49, in run
        _build_ext.run(self)
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 338, in run
        self.build_extensions()
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 447, in build_extensions
        self._build_extensions_serial()
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 472, in _build_extensions_serial
        self.build_extension(ext)
      File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 174, in build_extension
        _build_ext.build_extension(self, ext)
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 532, in build_extension
        depends=ext.depends)
      File "/usr/lib/python3.5/distutils/ccompiler.py", line 574, in compile
        self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
      File "/usr/lib/python3.5/distutils/unixccompiler.py", line 120, in _compile
        raise CompileError(msg)
    distutils.errors.CompileError: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 243, in run_setup
        DirectorySandbox(setup_dir).run(runner)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 273, in run
        return func()
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 242, in runner
        _execfile(setup_script, ns)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 46, in _execfile
        exec(code, globals, locals)
      File "/tmp/easy_install-l3j4uts0/cffi-1.11.4/setup.py", line 236, in <module>
      File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
        raise SystemExit("error: " + str(msg))
    SystemExit: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1087, in run_setup
        run_setup(setup_script, args)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 246, in run_setup
        raise
      File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 166, in save_modules
        saved_exc.resume()
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 141, in resume
        six.reraise(type, exc, self._tb)
      File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/six.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 243, in run_setup
        DirectorySandbox(setup_dir).run(runner)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 273, in run
        return func()
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 242, in runner
        _execfile(setup_script, ns)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 46, in _execfile
        exec(code, globals, locals)
      File "/tmp/easy_install-l3j4uts0/cffi-1.11.4/setup.py", line 236, in <module>
      File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
        raise SystemExit("error: " + str(msg))
    SystemExit: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-6f6bmdrf/pygit2/setup.py", line 202, in <module>
        **extra_args)
      File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 269, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 313, in fetch_build_eggs
        replace_conflicting=True,
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 826, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1092, in best_match
        return self.obtain(req, installer)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1104, in obtain
        return installer(requirement)
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 380, in fetch_build_egg
        return cmd.easy_install(req)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 663, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 693, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 873, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1101, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1089, in run_setup
        raise DistutilsError("Setup script exited with %s" % (v.args[0],))
    distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-6f6bmdrf/pygit2/
@flaper87

This comment has been minimized.

Contributor

flaper87 commented Jan 22, 2018

What distro are you using? You may need to install libffi-dev or libffi-devel depending on your distro. The real error is here: c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory

Check what package contains ffi.h and install that one. You may also need other devel packages.

Thanks for helping out :)

@pjanuario

This comment has been minimized.

pjanuario commented Feb 19, 2018

@flaper87 i gave another try to it, but unfortunately some other dependency is failing and i couldnt uninstall from the master branch. :/

Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-1nw79sb7/pygit2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-dlagnj1d-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-1nw79sb7/pygit2/

Not sure if this is familar to python devs and i didnt had enough time to proceed with digging on it.

@zcourts

This comment has been minimized.

zcourts commented Sep 20, 2018

@flaper87 I tried to get the helm module to work but failed miserably.
I gave up in the end and attempted to write my own, taking a very different approach. As the author of the current helm module I'm posting this mostly to get your thoughts on what I've done.

As of right now, it only supports installing your own helm charts from a directory but this is actually all I need. No matter which helm chart we install, we always add the upstream chart as a dependency and then customise values.yml in our own chart (or add other helm objects).
https://github.com/hypi-universe/hypi-ansible-modules/blob/master/helm_shell.py

The big difference you'll notice immediately is I'm not integrating with Helm/Tiller APIs, just going straight for the helm command. So to use this module the machine from which the playbook is executed must have helm installed and configured to use the right context for the env you want to deploy to.

My usage as of right now, looks like this:
In the playbook

- name: Install Helm Charts defined by Hypi
  hosts: kube-master[0]
  roles:
    - role: hypi-charts
      delegate_to: 127.0.0.1 #all our charts are deployed by running helm on the machine the playbook is executed from

in my roles taks file I then have a bunch of tasks to install stuff like this:

- name: Install Rook Ceph Operator
  helm_shell:
    namespace: default
    name: rook-ceph
    version: 0.8.1
    source:
      type: directory
      location: "{{ role_path }}/files/platform/rook"

The current implementation behaves like this:
if the chart is not deployed it is installed
if the optional state param is absent the chart is deleted
if version is == to the deployed nothing is changed (and ansible status correctly reflects this
if version > deployed version, the chart is upgraded
if version < deployed version, the chart is rolled back IFF the requested version has been deployed in the past i.e. you can't roll back to a version that hasn't been deployed before.
If there were multiple past releases with the same version the one with the highest helm revision number is taken.

There are a number of todos e.g. verify etc but this works reliably with the only dependency being helm installed on the deployment machine(which I think is acceptable, I fought with libgit2 because of various version issues to no avail).

This should work for upstream charts by simply specificing location: "stable/<chart-name>" but I haven't tested that.

I'll clean up the repo later and Apache V2 on it with readme/instructions but it took less time to write this than I spent trying to get the current module to work. Feedback welcome.

@dpmerron-ltd

This comment has been minimized.

dpmerron-ltd commented Sep 23, 2018

Nice work. I’ve actually cloned your work and made some changes to handle helm init & setting context etc.

Nearly finished and will submit a PR tomorrow!

@flaper87

This comment has been minimized.

Contributor

flaper87 commented Sep 25, 2018

@zcourts thanks a lot for the feedback and sharing your work. I honestly don't have the time to maintain and move this module forward. My focus changed after the module was accepted. I'd be more than happy to have this module deprecated in favor of yours or have any of you given access as maintainers :)

Let me know what you'd prefer. Like you could do a major refactor to the existing module and have it use your code.

@zcourts

This comment has been minimized.

zcourts commented Sep 29, 2018

Hey,
I'm happy to pick this up. We're heavily dependent on both ansible and helm charts so would ideally like to be using stuff from upstream. How do you want to move forward with this?

@flaper87

This comment has been minimized.

Contributor

flaper87 commented Oct 8, 2018

@zcourts I think a good first start would be for you to propose a PR with your changes and improvements. I can help with the review and pushing it forward. Once that's done, I think we can also add you as a reviewer of this module. How does that sound?

@zcourts

This comment has been minimized.

zcourts commented Oct 10, 2018

That works. I've got some Ansible work scheduled in a sprint starting next week. I'll drop some of this into it and raise a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment