-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Kustomize integration support #1261
Comments
There's a few bits of technical design we'd have to figure out: how does automation (updating the images used) work with kustomize config?Part of flux's API is that you can ask it to update the images used for particular workloads; and, you can ask for that to be automated. With regular YAMLs this is pretty straight forward. Since image values may be patched arbitrarily with kustomize, I think it would be pretty tricky without a fairly rigid convention for how to factor the config. Or maybe not? At a glance, it seems like it would be possible to be able to trace where an image was defined, and update it there; you'd probably want to lock base layers, so you're not updating things for any more than one environment. Anyway: needs some thought. when does kustomize run?It's not a big deal to run kustomize every time we want to apply the config to the cluster (with a period on the order of a minute). However: we also need YAMLs around for other circumstances, like answering API calls, which can happen arbitrarily. do we need some kind of plugin mechanism for this?We have special code for supporting Helm, in fluxd (and a whole operator!). Supporting Helm and kustomize would be great; supporting Helm and kustomize and, I dunno, ksonnet, would be cool; at some point though, baking things in gets pretty monolithic. They all have similar properties (Helm is a little different because of the indirection via charts, but similar enough). I wonder if there's a mechanism to be invented where the particular flavour of config is supported by a sidecar, or some such. One idea popped up in #1194, though it doesn't cover the automation/update requirement. |
It looks like the latest release of kustomize https://github.com/kubernetes-sigs/kustomize/releases/tag/v1.0.5) has support for setting image tags in the kustomization.yaml file, I wonder if this would help for automatic image changes? |
FYI: Support for kustomize has just been merged into kubectl: kubernetes/kubernetes#70875 |
Interesting! And neat. |
This is something that we are very keenly interested in. |
And now it's reverted 😭 kubernetes/kubernetes#72805 |
I have written a design proposal which, if successful, will result in Flux supporting Kustomize and other manifest factorization technologies. Comments are open, so please take a look and let me know what you think (answers to comments will be taken in a best-effort manner). My next step will be to write a proof of concept PR and run it by any interested parties. |
It's back in 1.14 as a subcommand: kubernetes/kubernetes#73033 |
I have a working solution for using Kustomize, see https://github.com/2opremio/flux-kustomize-demo Please take a look, if the feedback is positive we will end up merging it. |
We started to test this and it has been working ok but it raised a few questions that i would like to ask / see what you think about
I guess all my problems right now are about understanding how to divide kustomize and flux responsabilities
What are your / the community thoughts about this scenario ? |
@primeroz First, thanks for testing it!
It depends on where you place the Quoting the design document: For every flux target path [i.e. passed to If no
I guess the only way to know is by testing it. We read the output sequentially and my guess is it will be able to withstand quite a big size. If you encounter a performance problem, please let me know, I will be more than happy to address it. However, if you feel more comfortable, and based on the
It doesn't require one patch file for every workload, you can put all the workloads in the same patch-file. Also, as indicated in the demo's README, my plan is to modify kubeyaml (incorporating a flag like Note that, however you make it, when using an incremental patch-based solution like
It really depends on your particular use-case. I am happy to make suggestions if you describe your scenario (both qualitatively and quantitatively, so that I can estimate Flux's load), but ultimately it's about making your life easier. My goal with the proposed solution (and gathering feedback early) is to come up with a generic approach (covering not only |
Hi thanks for your response. i will do a bit more experimentation . This is what i was thinking to do anyway in terms of structure but i wanted to limit the amount of repetition between clusters overlays
For each cluster I will point flux to the right git-path clusters/XXX directory
I am not sure i uderstand this. I get it that I can put .flux.yaml in a parent directory so to share it between different overlays/clusters definition.
Would i need to pass two git-path to flux in dev1 ( one for apps and one for core ) or by specifying just one git-path would be enough for flux to find the 2 subdir apps and core ? Thanks for the hard work though, this looks really good for us! |
Looks good
If the approach is validated I will definitely implement
Out of curiosity, why can't you? Is it because This is how I originally implemented the demo (after modifying
Weave Cloud offers this feature, by using Flux's API to propagate changes across environments. Note that this is a separate problem to using
This sounds low-tech, but if you only want to propagate image versions seems like a pretty good approach. Note that it can be a bit fragile if you don't have the same workloads in each environment (otherwise, you may end up deleting the image overlay of a workload in the destination without corresponding workload in the origin). Similarly, for this approach to allow separate annotations between environments I would use two separate patch files, one for annotations and one for images.
It depends on what you put in your The key to understand this is that the Quoting the updated design document: |
Upon further checking that's not really true (right now we read the full file while parsing, which we can easily change) but I think it will tolerate large sizes. Can you report on the output sizes you will have? If it's in the order of a few dozen megabytes I think it should be fine. |
Sorry for late reply, holidays in between!
That would be great for us
Correct. that would create common annotation that would apply to any resource created by that kustomization file
Just over 1MB right now and is working fine. I guess i was worrying about something before checking if it was a real deal. I will keep an eye on it and possibly create an example where i can reach a >24MB size and see how it goes ( That will be a lot of resources! ) |
Would be nice to see this implemented as kustomize seems to be becoming the defacto standard for declarative templating with it being merged into kubectl. |
@rdubya16 by this you mean the working implementation mentioned above? :) |
@2opremio This is my first look at flux so I can't really speak to this implementation. We are managing yaml files with kustomize checked into git but want to make the move toward gitops in the next few months and was hoping there was kustomize support so we wouldnt have to do something hacky like OP. |
@primeroz Is this the only blocker? Would you be happy to use it without any other modifications? |
@rdubya16 did you check https://github.com/2opremio/flux-kustomize-demo ? |
@2opremio yeah i think so. I am getting back onto this right now since i spent most of my last week on porting our self-made terraform kubernetes onto GKE and only got our "bootstrap flux" done for now ( which just uses jsonnet generated yaml manifests) I am getting onto the apps section now , for which i want to use kustomize , so i will update you once i got more info from my first experiments though i think that is the only blocker i see |
Also doing a proof of concept (with promotion from dev -> staging -> prod now using this). I think we want to achieve a similar pattern to https://www.weave.works/blog/managing-helm-releases-the-gitops-way , but using kustomize instead of Helm :) @2opremio just wondering on the use-case for annotations in the demo. At the moment we would have annotations for various services defined in kustomize overlays, like
In general, I don't think flux would ever need to change this, unless we were to use something like Is that fairly common (i.e. in our |
I think it would be great to improve error management out of the kustomize / flux implementation I had an issue where I did not add the key to a remote Kustomize bases repo that the one flux cloned uses for remote bases. It took a long time before getting any errors in the logs :
Also once i fixed the issue ( adding the key to the remote ) it never recovered ( retried on its own ) until i killed flux |
I totally agree, it's in the list. See https://docs.google.com/document/d/1ebAjaZF84G3RINYvw8ii6dO4-_zO645j8Hb7mvrPKPY/edit#heading=h.7fpfjkabanhy
You can force a sync by running
Uhm, please make sure to let me know if it happens again. It may be a bug in the implementation. |
@primeroz thanks for bringing it up. Yes, we need to improve debugability. It's planned, but will be done after #1848 lands. You can read more about it at debugging section of https://docs.google.com/document/d/1ebAjaZF84G3RINYvw8ii6dO4-_zO645j8Hb7mvrPKPY/. I think it will cover both (1) and (2). Let me know what you think commenting directly in the document |
That's probably a bug in kustomize , maybe it's already fixed upstream. I will take a look. |
@nabadger I went through the history and found the problem, there is a fix for it at bd7fa14 |
@nabadger I've only found kubernetes-sigs/kustomize#566 , whose fix has been released in Kustomize 2.0.3 (which is the version we ship with flux in this PR). Would you mind creating an upstream issue? |
@2opremio Ye, I'll wait for it to be merged, so at least this feature is kinda stable :) |
@2opremio Is there a reason that the patchFile item is required in .flux.yaml ? It seems to work when you point to an empty yaml but won't work without that item missing. If you don't need any flux specific edits on top of your kustomize files, it seems kind of strange to require unless im missing something. |
Will this support the helm operator as well? Or is that a feature to do when this one is complete? |
@guzmo Support in what way? |
Well, will it be possible to change the "spec.values" key inside "kind: HelmRelease" yaml files. Maybe it's obvious it does :P But since that's another container running ( helm operator ) I thought maybe it will not be supported in the first version. |
If Kustomize can do that, this PR will be able to do that. (whether Kustomize can or not is unclear to me, but I think there's a pretty good chance) |
@rdubya16 It only works with an empty yaml because of a bug I fixed in bd7fa14 . If you want include the generators and omit the updaters use a |
@guzmo Kustomize or any commands included in the flux image (e.g. templating using a shell script). In the future (when Ephemeral containers land in Kubernetes) we will let you use any commands supplied by a container image you specify. EDIT: @guzmo we can add additional commands you think will be generally useful for factorizing manifests. |
@2opremio Found an issue where
I failed to supply the This results in a commit which deletes the contents of
|
@nabadger I need to check the code (or an example). Do you have a simplified reproduction? Otherwise, can you show me the logs and the contents of |
@2opremio I think fluxctl release command fails to push to the repository when we merge multiple services at the same time ( guess because it has to fix merges in the flux-patch.yaml? ). Is this something you have noticed? The problem might go away when the flux-patch has most of the services, but it's boring to see a lot of failed pipelines and rerun them because it might be this :) |
@guzmo No, I haven't seen that. I am more than happy to take a look but I need specifics of how to reproduce (ideally with a totally reproducible step by step example). |
@2opremio I haven't been been able to reproduce my earlier errors yet related to the deletion of
Which is probably expected error handling of some sort? |
I have however found an issue with automation via weave annotations when using the kustomize Let me know if I should keep raising issues in this case or separate ones. I noticed that flux is not updating images based on how you define the annotations. It might be useful to set automation policies in a base kustomization for a specific type of environment, like so (I'm fine not doing this, but others might like such a feature): kustomization.yaml
Whilst flux will think the workload is automated, it doesn't apply any new images. I set the various sync options to
If i bump the image version for a demo app I get the following. It should jump to 0.0.11 from 0.0.9
If however I add these annotations as a patch onto the deployment (and not using kustomization.yaml
deploy-patch.yaml
Could this be related to the image-poller checking annotations on non Deployment kinds? If we use I see this warning in the flux logs which means it at least attempts to deal with this:
|
It's hard to tell what the exact problem is, but please retry with Flux 1.12.3 (which includes #2054 ) to be released later today. I will also update the image in #1848 to include it |
That's strange, since Flux doesn't distinguish where the annotations come from
Ah, it could be. I don't think we should fail on that, I believe it should be a warning. However, this isn't directly related to the current issue. Could you create a separate ticket for it? |
@2opremio Ive been playing around with this build for the last week or so. Seems like it will suit our purposes. Ive ported most of our existing yaml over to use it in a sandbox environment and seems to be working well. I don't have any suggested changes just want to add my support for this implementation. |
Sorry for late reply. Got no time right now to create something reproducable I’m afraid :( only thing we did was merging two services at the same time so our build pipeline ran fluxctl release almost at the same time. So my guess is that the flux-patch.yaml had merge conflict when flux tried to push. |
@2opremio - just letting you know that this is still working well for us. Something I noticed is that listing workloads and listing images via I was wondering if this is expected, since I thought maybe this information (at least for images) could be fetched from memcache instead. The impact of this can slow response times for In our use-case fluxctl commands like listing images were taking upto 10 seconds. We've since switched to a monorepo for our kustomzie configuration, so now it's back down to around 1 second. |
Yeah, we haven't looked too deeply into performance yet. The first step is to release a functional and (at least reasonably) stable feature.Thanks for the report though. @squaremo will be in charge of merging it toaster soon |
Very toaster! |
Hahahaha, I meant "to master", damn corrector. |
🎊 #1848 is merged! 🎉 You can now use a flux image from the official pre-releases repo: https://hub.docker.com/r/weaveworks/flux-prerelease/tags, and set the |
Flux should support kustomize integration so that the source repo can contain a base and overlays and have flux deploy the merged specs. Today, I solve this by having the base & overlays in a repo and a secondary CI job that runs
kustomize build
and commits these into a second repo.The goal is to automate this and make the source of truth the separate specs (base + overlay).
I'm happy to contribute on this, just wanted to see if this was started and if it would be accepted.
The text was updated successfully, but these errors were encountered: