Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Helm support for single or multiple values files #93

Closed
telemaco opened this issue May 13, 2020 · 4 comments · Fixed by #236
Closed

Helm support for single or multiple values files #93

telemaco opened this issue May 13, 2020 · 4 comments · Fixed by #236
Labels
has_pr This issue has a related PR that may close it. topic/helm Issues relating to helm plugins type/enhancement New feature or request

Comments

@telemaco
Copy link

SUMMARY

Could be interesting that the helm module will support single or multiple values files.
Helm command itself support it adding "-f values.yaml -f values2.yaml"

ISSUE TYPE
  • Feature Idea
COMPONENT NAME
  • helm
ADDITIONAL INFORMATION
@orjan
Copy link
Contributor

orjan commented May 14, 2020

Since the module is taking values we can combine the files with Ansible without having to use the built in support in helm for multiple files. I'll guess something like this might work?

---
- hosts: all
  vars:
    default_vars: "{{ lookup('template', 'default.yaml') | from_yaml }}"
    override_vars: "{{ lookup('template', 'production.yaml') | from_yaml }}"
  tasks:
    - name: Combine values
      debug:
        msg: "{{ default_vars | combine(override_vars) }}"

https://github.com/ansible-collections/community.kubernetes/blob/master/plugins/modules/helm.py#L150

@loomsen
Copy link

loomsen commented May 29, 2020

I have a similar use case, where I have a common values file, and I'd like to define the overrides in the helm task in the playbook itself, to make it more readable. For example, prometheus could be installed with alertmanager in stg and prd, but without in dev. It would be nice to have a common file, and have tasks in the playbooks like:

        - name: install prometheus
          helm:
            chart: stable/prometheus
            name: prometheus
            namespace: monitoring
            values_file: /path/to/common/values.yml
            values:
                 alertmanager:
                   enabled: false

Would be nice to have a way to combine those, like for example a values_file parameter. I have tried to combine it in different ways, but none of them worked. So now either I have to have different template files for each environment, even though they might just differ in one line, or I would have massively long and unreadable playbooks, all due to the huge prometheus values.yaml when you define custom scrape configs and whatnot.

So what I ended up doing in the end, which imo is not very nice:

        - name: install prometheus
          helm:
            chart_ref: stable/prometheus
            name: prometheus
            release_namespace: monitoring
            values: "{{ default_values | combine(overrides) }}"
          vars:
            default_values: "{{ lookup('template', '{{ playbook_dir }}/helm_values/prometheus.yml') | from_yaml }}"
            overrides:
              alertmanager:
                ingress:
                  hosts:
                    - alertmanager.{{ cluster.dns.internal_domain }}
                  tls:
                    - hosts:
                      - alertmanager.{{ cluster.dns.internal_domain }}

@telemaco telemaco reopened this Jun 18, 2020
@telemaco
Copy link
Author

Sorry for the close and reopen. I just want to comment that I've similar situation than @loomsen.

@ggee
Copy link

ggee commented Jun 18, 2020

Same situation. Above works but not clean.

@tima tima added topic/helm Issues relating to helm plugins type/enhancement New feature or request labels Jul 1, 2020
@Akasurde Akasurde added the has_pr This issue has a related PR that may close it. label Jul 10, 2020
@tima tima closed this as completed in #236 Oct 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has_pr This issue has a related PR that may close it. topic/helm Issues relating to helm plugins type/enhancement New feature or request
Projects
None yet
6 participants