-
Notifications
You must be signed in to change notification settings - Fork 187
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
Add support for in-line generic patches to Flux Kustomization API #364
Conversation
9bbfbed
to
4040c1e
Compare
Allow patching multiple resources instead of a single existing one as StrategicMerge & JSON6902 are forced to target existing named resources. Signed-off-by: Guillaume Le Biller <[email protected]>
4040c1e
to
b797eac
Compare
Converted the PR to draft while waiting for pkg PR #109 |
To add [Kustomize `patches` entries](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/patches/) | ||
to the configuration, and patch resources using either a [strategic merge](https://kubectl.docs.kubernetes.io/references/kustomize/glossary#patchstrategicmerge) | ||
patch or a [JSON](https://kubectl.docs.kubernetes.io/references/kustomize/glossary#patchjson6902) patch, | ||
`spec.patches` items must contain a `target` selector and a `patch` document. |
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.
items must contain a target
but in the blow example there is no target specified
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.
Thank you for the catch :)
In the original Kustomize resource, it's possible to apply a strategic merge patch (not JSON6902) without specifying the target.
I decided to force the target to be present in the Flux implementation for simplicity. Maybe that is something could be added in the future.
Having more than one Kustomization that points at the same path is not something you should ever do, as the controller will delete and recreate everything. Why are you doing this? |
@Kissy please update apis/kustomize to |
The use case I have in mind is:
Each git repository can be handled by a PR & permissions per teams with fine grain settings. On the other side, the Infra team is managing a single repository with:
(1) Would be a The Infra repo is clean and adding a new app / removing an app is done by adding or removing file in the |
I think this patch could be almost identically applied to the helm-controller which also has support for JSON6902 and strategic merge patches at the moment. |
@hiddeco I'm not sure it would work in all cases, as the patch can be on disk. While KC has the full source locally, HC doesn't. I don't expect people to place patches inside the chart, but for Git could work... |
Thanks @Kissy now I understand your use-case, the path is the same but the source is different so no conflicts 👌 |
@Kissy apis/kustomize |
Signed-off-by: Guillaume Le Biller <[email protected]>
Successfully ran a test with an external cluster with:
|
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.
LGTM
Thanks @Kissy 🏅
The
patchesJson6902
orpatchesStrategicMerge
fields in a Kustomize resource only allow patching single named resources. In order to patch multiple resources with a single patch, the genericpatches
field need to be used.This PR implement the generic
patches
at the kustomize.toolkit.fluxcd.io/v1beta1/Kustomization level to unlock that feature.One use case, would be for instance to override all path of all Kustomization at once without having to patch then one by one:
The field
options
from the original Kustomization is not implementedThis PR can only be merge if pkg PR #109 is accepted.