-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
feature(helm): Added template support for config and collector files #642
feature(helm): Added template support for config and collector files #642
Conversation
Hey @Avihais12344, I'm not sure I follow, but I think it already works the way you imply. sql_exporter has a discovery mechanism to search for external collector files (with globbing if needed) and use them. As per the docs here:
So we can avoid unnecessary templating by using the native functionality, via attaching configmap resources to the designated location. Adding @allanger for visibility. |
Hey @burningalchemist, It could also help users so they could use variables and values at the values files themselves, for example, matching the idle connection to the connection, using variables. So, I don't think it's unecessary. |
As I remember, the I don't feel like merging all the possible config files to this repo. |
I guess we're referring to this helm topic: https://helm.sh/docs/chart_template_guide/accessing_files/. If I'm reading it right, it implies bundling the specific files in the chart, as @allanger mentioned above. Then I'm confused on how can we use it, when the new chart is released (without any pre-baked custom files, of course). 🤔 Correct me if I'm wrong, but I guess there is no native way to deploy extra yaml files together with the chart out of the box (unless you create some wrapper charts). It's still possible with some extra tooling (which sort of wraps/orchestrates helm and regular manifest deployment, like skaffold or alike), but then it really depends on the user environment, their tools and goals. So I'm not sure we need to solve the problem in the chart itself. 🤔 |
You don't need to merge any possibility. A user that wishes to add a config file, just does something like that at the values file: collectorFiles:
pricing_data_freshness.collector.yml: "{{ .Files.Get \"my_collector.yaml\" }}" And the user would also have the file @burningalchemist I think when they say at the docs that:
I think they mean that the content of the file would be part of the final release deployed on
As they talk about the I think it's a small fix, to help many users, like me, who want to not put all the configs at the same values file, or use multiple values files and try to concatenating them together, or use additional tooling. I work in a limited environment, so I can't have all the fancy things in the world. And even if files are not a strong argument for you, you can use templates to apply other magic for your values. For example, configure this at the values file: config:
global:
# -- Scrape timeout
scrape_timeout: "{{ .Values.serviceMonitor.interval }}" So now, the In addition to that, I think that a user who wants to deploy a new instance of |
Have you tested it with a file that isn't stored in the same dir as the chart? |
Okay @allanger, I have tested it, and it doesn't work as I though it would. I am sorry, I am just regular to clone the chart, and work with the chart at it's directory. So, even if it doesn't work with files outside the dir of the chart, I still think it's necessary. I think it's much easier to clone the chart, and add the files yourself, than using |
Charts are not supposed to be distributed in that way, I'm sorry, but I don't feel like adding some functionality that would mean that we need to shift the responsibility to maintain the chart to users. And it would end up in requests to add more configs to the upstream repo. I've thought about adding templates to the config to make it possible: config:
global:
# -- Scrape timeout
scrape_timeout: "{{ .Values.serviceMonitor.interval }}" But I'm not sure if it makes sense, as there are not so many values that are shared between k8s objects and the exporter config. But I think it's not up to me to make decisions though |
@burningalchemist we may need your help. |
Hey folks, I'm out of capacity at the moment to respond quickly. I'll try to allocate some time in the coming days, hope it's ok for you. |
@burningalchemist still out of capacity? |
Hey @Avihais12344, @allanger, Thank you for your patience. I've spent some time last week looking into the domain, and I bumped into several discussions (#3276 and the respective PR #10077) which are quite heated. I've read through them and I have a few thoughts on the matter. Overall, the problem of adding arbitrary files to Helm charts is pretty controversial and not solved yet. If you treat Helm charts as a package manager, then it's not a good idea to allow arbitrary files to be added for many different reasons (including distribution, artifact integrity, security, maintenance, etc). However, if you treat Helm charts as a way to package up Kubernetes resources (in other words, just a template generator), then it's normal to expect arbitrary files to work out of the box. It seems there is no common consensus at the moment, which is an issue. What we are trying to achieve in this PR doesn't look like a solid solution to me. On one hand it simplifies some steps for a limited group of users, but on another hand it's clearly a hack. In this case, having a sub-chart, despite its suboptimal nature is more common in the community, so it's easier to grasp and apply this practice. Whenever there is a proper solution in the upstream on how to treat and inject arbitrary files, we should definitely adopt it. Until then, I'm not sure if we should be promoting hacks, as it also puts a burden on the maintainers to support it and the users. Having said that, one possible alternative I see is to utilize On the parameter templating, I don't think it's needed here as well. The number of parameters is small, and it's not a big deal to provide them manually. I'd rather keep the chart simple, flexible, and easy to understand. |
I understand the problem with files, thank you for your research. But I disagree about the parameter templating, even if it's small, I still think it's good to support it to make the chart more flexible, and still easy to understand and use. |
Hey @Avihais12344, well, I don't want to be a blocker if you really think it provides the value and flexibility. Let's try it out then. :) My only change request would be to mark that config parameter in docs as optional (so we have the compatibility) and remove the What I'd like to avoid personally is multiple Github issues (helm-related in this case), which oftentimes are mistakenly marked as bugs, though users just cannot configure their stuff or debug based on the error messages. It's pretty time-consuming and I don't have this time sadly and I don't want to use much of @allanger's time as well, so I tend to make it simple. |
@burningalchemist Sorry for the delay, I have done as you say. But I do not understand why make the |
@Avihais12344 No worries at all, it's a holiday season. 👍 I only meant that to make sure that the previous configuration approach is still applicable, but seemed to introduce confusion. 🙂 If you think nothing really changes, we can remove that note. Configuration cannot be optional, of course. 👍 |
@burningalchemist Thank you very much. I have removed the note about the optional config. And of course the old way still works, so no need for notes. I am done now. |
Thank you too! 👍 I'm waiting for the checks to pass, and merge it. |
Added support to use helm templates at
.Values.config
and every key at.values.collectorFiles
so you can better organize your values file.For example, instead of doing this:
You can put the config at a different file (
my_collector.yaml
for example):And use it like that:
And it works same as the old one, and your files are also organized better.