-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Strategic merge support for CRDs #2825
Comments
possible dupe of #1510 |
cc @eddiezane could we do this during the bug scrub? |
We're currently hacking around this by loading the CRDs schemas directly (our CRD schemas are in the format that AddSchemaFromFileUsingField expects): prydonius@7610688 |
/assign @monopole |
This should be resolved as part of the migration to kyaml. Users will be able to override the merge keys on a per-field basis. |
@pwittrock that's great, although it would also be nice to just inherit merge keys from existing types (e.g. PodSpec) somehow. Are there any docs on how to set the merge keys with kyaml? |
@monopole @natasha41575 This issue is related to #3111. Users may want to load their own schema. |
@monopole In case you haven't started working on the issue, I'd like to work on it and hopefully submit a PR. Also, I might need some initial guidance regarding how to implement this. |
@serhatcetinkaya I have a proposal for this and am working on an implementation, but I'm happy to hear your thoughts about it. |
After some discussion with @monopole, the SIG-CLI group and others, we have created a KEP to allow users to specify their own custom schema files. See kubernetes/enhancements#2206 and https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/2206-openapi-features-in-kustomize. When this is implemented you will be able to fetch the openapi schema from your kubernetes cluster, change the merge keys, and use your custom schema via an openapi/path field in the kustomization file. Hopefully that is enough to resolve this issue for now. |
You can now specify your own custom OpenAPI schema file to use with kustomize via an You can also now fetch the OpenAPI schema from your kubernetes cluster with the command Closing this issue. |
I'm building a simple CRD that contains a PodTemplate under
spec.template
and I found that, unlike a Deployment which has the same spec, the strategic merge isn't handled correctly by Kustomize, leading to overwritten fields.For example:
given the following base:
applying the following overlay:
the resulting manifest is:
The
spec.template.spec.containers
array gets entirely replaced, rather than merged based on thename
field value (such as for a Deployment).I found that the issue here is that Kustomize does not have the schema for my CRD and so does not have the patch strategy and merge keys defined for it to be able to perform the correct strategic merge. If I fork Kustomize and call
AddSchemaFromFileUsingField
with the appropriate schema (in this case, pointing to the original PodTemplateSpec definition), I'm able to get Kustomize to correctly overlay my patch:result:
Proposal
It would be great if there was a way to load in my CRD's schema with patch strategy and merge key information, so that Kustomize can apply patches as intended. There is an existing
crds
field in the Kustomize spec which appears to be for this use case, but as far as I can tell it's only used to create a TransformerConfig. Could we use this field for both the TransformerConfig and loading the OpenAPI schema for strategic merge?A slight issue is that the structure that
LoadConfigFromCRDs
andAddSchemaFromFileUsingField
has slightly different nesting, though the underlying schema is the same OpenAPI format (see this example for the TransformerConfig). We would need to choose one of these formats and load both the TransformerConfig and add the OpenAPI schema from the chosen format. Additionally, I've seen that some people have asked if thecrds
field could load the full CRD definition and the OpenAPI schema from thevalidation
field. Perhaps changing it to load this would make the most sense?I'd be happy to submit a PR to do this, if we think this is the correct approach.
The text was updated successfully, but these errors were encountered: