-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
fea(#507): support assign --post-renderer
flags , helmDefaults config , release config when use helm v3
#510
Conversation
--post-renderer
and `--post-renderer-arg…--post-renderer
and --post-renderer-args
within args in helmDefaults when use helm v3
pkg/helmexec/exec.go
Outdated
// reset the postRenderers and filter the post-renderer args from args and put into helm.postRenderers | ||
helm.postRenderers = nil | ||
for _, arg := range args { | ||
if strings.HasPrefix(arg, "--post-renderer=") || strings.HasPrefix(arg, "--post-renderer-args=") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when use a format like the below:
--post-renderer value
what will happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this format will be deal with analyzeArgs , and keep the args order then past into helm command:
such as :
helmfile -e ksp -f ti-k8s/helmfile.yaml -l chart=mysql --args="--post-renderer rewrite-ksp.sh" --debug
the helm command is :
helm template mysql mysql --namespace ti-inf --values /tmp/helmfile3923818193/ti-inf-mysql-values-674855cccb --values /tmp/helmfile1141692238/ti-inf-mysql-values-9b4dd874f --values /tmp/helmfile2042720088/ti-inf-mysql-values-5448c6fcbd --values /tmp/helmfile1303814841/ti-inf-mysql-values-776bd65866 --post-renderer rewrite-ksp.sh --debug
so these will also work well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if strings.HasPrefix(arg, "--post-renderer=") || strings.HasPrefix(arg, "--post-renderer-args=") {
will --post-renderer=vaule
--post-renderer value
all be handled?
@tanguofu Need most units and e2e tests. |
@tanguofu BTW. please fix ci issue and add tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! I just took a glance at your awesome work. One question- Although you mentioned helmDefaults in the PR title, the actual change does not contain anything related to helmDefaults.
Are you also willing to add the post renderer support to helmDefaults too? That would be great if so.
i think it is not a good idea to add a new config
and more resue the
this will make this feature more easy to use. |
@tanguofu Helmfile is designed for use when you want to manage a set of releases declaratively. If you need a specific post-renderer to make your release(s) get deployed properly, I consider the post-renderer a part of the deployment, which means it should be covered in helmfile.yaml.
We don't retain forward compatibility in Helmfile. I think that's generally the same stance as other projects within the K8s community. We do maintain backward compatibility. In the context of backward compatibility, adding new fields is fine. |
well let me add the |
the many thanks ! |
pkg/argparser/args.go
Outdated
if len(state.HelmDefaults.PostRenderer) > 0 { | ||
argArr = append(argArr, fmt.Sprintf("--post-renderer=\"%s\"", state.HelmDefaults.PostRenderer)) | ||
} | ||
for _, arg := range state.HelmDefaults.PostRendererArgs { | ||
argArr = append(argArr, fmt.Sprintf("--post-renderer-args=\"%s\"", arg)) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is not the right place to add this code- The helmDefaults args, the under pinning of the --args
flag of helmfile, has known to be not well-designed, and being removed in Helmfile v1. The main difficulty is that Helmfile has no way to know which args specified in the helmDefaults.args to be passed to which helm sub-commands (install, uninstall, list, diff, etc) a helmfile command is going to run.
More importantly, the post renderer should be passed down to chartify
when you're going to use a directory of raw k8s manifests as a chart, or a kustomize config as a chart, or you're using some chartify-provided features like ad-hoc dependencies and ad-hoc patching(jsonPatches and stragicMergePatches, forceNamespace, and so on).
Still curious- did this actually work on your machine? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, the --args
flag of helmfile is easy to use indeed, such as:
helmfile -e ksp -f ti-k8s/helmfile.yaml -l chart=mysql --args="--post-renderer=`pwd`rewrite-ksp.sh"
as the post renderer
accept a abs path of exec script, this works well in our project;
though it is more chartify
to special each flags to parse the flags to helm exactly; but based on what I know, it is need to refactor lots of code, may be change the helmexec.Interface
and add some set methods
? and invoke at every place of helmexec.SetExtraArgs
?
So what is the good way to implement this feature? @mumoshu may you give some guidelines please ?
thanks very much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this works well in our project;
Yep. But it's not guaranteed to work. We don't have a complete design doc and tests to make sure your usage of "--args" works. My understanding was that Helmfile must have been implemented to pass the args to every helm sub-commands, regardless of if the sub-command supports the set of args or not.
Also note that it's being removed in Helmfile v1 https://github.com/helmfile/helmfile/blob/main/docs/proposals/towards-1.0.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the good way to implement this feature
I'd recommend following the same pattern that is used for other Helmfile flags and fields. Propagate Helmfile flags to helmDefaults
or Override<WHATEVER>
fields, inherit helmDefaults to releases[] fields if necessary, apply overrides from flags if necessary, and finally compose chartify parameters and helm flags from the final releases[] entry fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tanguofu Can you implement the change suggested by @mumoshu? The solution with the possibility to set the post-rendering through flags, helmDefaults or per release sounds perfect. Missing Post-rendering is the only thing stopping me from switching to Helmfile, so I'd be very grateful. Keep up the good work, guys!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i will implement the change, please just wait a moment.
@tanguofu any updates? |
@mumoshu any updates on this one? |
This is very useful feature. Will this be merged soon? |
@tanguofu waiting for your updates. thanks very much. |
@sherifkayad @KR411-prog This is an open-source project driven by volunteers. Instead of a storm of "any updates / eta?" messages that force anyone to work on it for you for free, you and we should all be encouraged to contribute via code, test results, or sponsorships that help the work to be done, if you need it! |
sorry for late to update here,it is a bit lot work to fix by @mumoshu guides。 If this patch canbe merge i'd like to implement may i have @mumoshu to take code review again, As i am unpracticed to the strict code sytle,many thanks @mumoshu @yxxhero to give me advice or comments。 |
@mumoshu That's an interesting take on questions / issues placed to your projects .. in years of using / trying (as much as I can) to enhance projects that I find doing something useful, that's really the first time I get such an unprofessional response from a maintainer .. anyways let's just get a few things clear here:
|
@tanguofu Thanks very much. |
@sherifkayad From a professional volunteer opensource maintainer who usually works in mornings, nights and Sundays for everyone in the world for almost free and kept it for years, and who gets asked "What's ETA of something" and "Is there any update on this" thing so often, it's my responsibility to clearly state my stance, to avoid us maintainers and opensource contributors from burning out. I take that's one of my jobs as the primary maintainer of this project. If I didn't do it, who does it? Who saves us from burning out? Also, you can always say something like "cheers!" or prefix your message with "Thanks a lot for all your efforts here! But ..." or something like that. Isn't that what we usually do in our real lives..? At least that's how I treat the maintainer or the contributor outside of this project, where I'm just an user of an opensource project. All that said,
I have something to learn from this 😉 Thank you for your feedback. But again, at the same time, I hope every open-source user is more thoughtful about who's volunteering unpaid hours to respond to all your never-ending requests. That's the right behavior if you're maintaining an open-source project that is a part of your open-core business. However, Helmfile is different- Helmfile isn't tied to any business entity and it's completely driven by volunteers, no VC backed. Sorry if this all sounded very "unprofessional". But that's how I continued this "job" for years. Lastly, I tend to just put a 👍 on the pull request when I absolutely need something to be merged in a random repo, so that you can express that you need it without inviting more pressuring messages to the pull request. Just my two cents. |
@sherifkayad Don't get me wrong. I do this to everyone who does the same. I'm not personally blaming you (sorry if it sounded so). It's not your fault at all if you have no time to contribute code or anything. It's due to the broken open-source economy. But still, I have to protect folks from burning out today, and, well, what you call "storming" turned out to be the only way that worked for me, unfortunately. |
Well sorry for going too out-of-topic. @tanguofu Thanks for the update! I've just reviewed your changes and almost everything looks great! One thing I have noticed is that you might need to add the post-renderer support also to our helm-diff wrapper code that is invoked on helmfile-diff and helmfile-apply. Let me see if I can add the support myself. UPDATE: 6c861ba should do the job. So far I was able to manually test it to work with:
Run
|
@mumoshu I support you. |
Let me try if I can distill my manual test procedure into a new E2E test-case to keep it working. Once that's clear, I think this is ready to be merged. |
@mumoshu I think all is good. |
@tanguofu maybe need some docs. |
Added an E2E test-case via d5bd31d |
@mumoshu seem like we should add helm-diff when e2e. |
--post-renderer
and --post-renderer-args
within args in helmDefaults when use helm v3--post-renderer
within args in helmDefaults when use helm v3
--post-renderer
within args in helmDefaults when use helm v3--post-renderer
flags , helmDefaults config , release config when use helm v3
@tanguofu I will help you to fix e2e test. |
…` within args in helmDefaults when use helm v3 Signed-off-by: guofutan <guofutan@tencent.com> Signed-off-by: yxxhero <aiopsclub@163.com>
…patibility when there is blank in the args values. Signed-off-by: guofutan <guofutan@tencent.com> Signed-off-by: yxxhero <aiopsclub@163.com>
…fault of helmfile.yaml Signed-off-by: guofutan <guofutan@tencent.com> Signed-off-by: yxxhero <aiopsclub@163.com>
…elmdefault or release config 1. only implement post-renderer flags this patch 2. As mumoshu advise, add helmfile flags `--post-render` and add the postRenderer config in helmDefaults and release. the priority is helmfile flags > release > helmDefaults. 3. fix the test case in state_test.go and some other tests. Signed-off-by: guofutan <guofutan@tencent.com> Signed-off-by: yxxhero <aiopsclub@163.com>
Signed-off-by: Quan TRAN <account@itscaro.me> Signed-off-by: yxxhero <aiopsclub@163.com>
* Allow running images with users other than root Signed-off-by: Patrick Hobusch <patrick@hobusch.net> Signed-off-by: yxxhero <aiopsclub@163.com>
Signed-off-by: yxxhero <aiopsclub@163.com> Signed-off-by: yxxhero <aiopsclub@163.com> Co-authored-by: Quan TRAN <itscaro@users.noreply.github.com> Signed-off-by: yxxhero <aiopsclub@163.com>
All the dependencies get correctly installed when dealing with remote charts. If there's a local chart that depends on remote dependencies then those don't get automatically installed. See #526. They end up with this error: ``` Error: no cached repository for helm-manager-b6cf96b91af4f01317d185adfbe32610179e5246214be9646a52cb0b86032272 found. (try 'helm repo update'): open /root/.cache/helm/repository/helm-manager-b6cf96b91af4f01317d185adfbe32610179e5246214be9646a52cb0b86032272-index.yaml: no such file or directory ``` One workaround for that would be to add the repositories from the local charts. Something like this: ``` cd local-chart/ && helm dependency list $dir 2> /dev/null | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done ``` This however is not trivial to parse and implement. An easier fix which I did here is just to not allow doing `--skip-refresh` for local repositories. Fixes #526 Signed-off-by: Indrek Juhkam <indrek@urgas.eu> Signed-off-by: Indrek Juhkam <indrek@urgas.eu> Signed-off-by: yxxhero <aiopsclub@163.com>
Signed-off-by: yxxhero <aiopsclub@163.com>
Signed-off-by: yxxhero <aiopsclub@163.com>
Signed-off-by: yxxhero <aiopsclub@163.com>
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com> Signed-off-by: yxxhero <aiopsclub@163.com>
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com> Signed-off-by: yxxhero <aiopsclub@163.com>
Signed-off-by: yxxhero <aiopsclub@163.com>
Oops I pushed something to main by mistake and that closed this pull request... Let me fix it and resubmit this. |
Okay we already disabled the ability to force-push |
@tanguofu Thanks again for your contribution! We'd appreciate it if you could help in writing documentation about this feature when you have some time. |
Signed-off-by: guofutan guofutan@tencent.com
This implement reuse the args in helmfile args and helmDefaults config of helmfile.yaml, these PR to maske sure the less change to helmfile code, but make sure the forward compatbility of the helmfile.yaml syntx