You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When generating schemas that reference external types, sometimes it is helpful to be able to avoid setting 'default' markers for fields within the type's schema.
As noted in kubernetes/kubernetes#95587 - it is recommended that defaulting should be skipped for templates of other resources (instead allowing the apiserver to set these defaults with this template is actually submitted to the apiserver).
Without a way to avoid generating these defaults, any controller that relies on hashing of say, a PodTemplate to determine whether an update is needed to the Pod will not be able to know if the object has actually changed and needs an update, or if a new field is introduced.
This is especially problematic when you consider stateful systems, as a change to a CRD that introduces a new default value will trigger a re-creation of all underlying pods.
Many alternatives are discussed in kubernetes/community#6764 to solve this, including having controllers only hash the fields they are interested in. This is problematic because over time as new fields are added, controllers may 'miss' these and therefore not trigger updates when the value is actually changed either.
Proposal
Adding a new marker that can be set on fields, e.g. //+ kubebuilder:default:skip=true which will cause default values to not be set in the generated sub-schema.
The text was updated successfully, but these errors were encountered:
My only concern when implementing this so far, is currently markers do not recurse into sub-schemas. Is this intentional, and are there issues in doing this sort of recursive lookup?
Sounds reasonable to me. No idea, about the recursive lookup.
Not really familiar with the current implementation but maybe some sort of "post-processing" to remove previously added defaults recursively would work? (not sure if that's different to what you suggested)
When generating schemas that reference external types, sometimes it is helpful to be able to avoid setting 'default' markers for fields within the type's schema.
As noted in kubernetes/kubernetes#95587 - it is recommended that defaulting should be skipped for templates of other resources (instead allowing the apiserver to set these defaults with this template is actually submitted to the apiserver).
Without a way to avoid generating these defaults, any controller that relies on hashing of say, a PodTemplate to determine whether an update is needed to the Pod will not be able to know if the object has actually changed and needs an update, or if a new field is introduced.
This is especially problematic when you consider stateful systems, as a change to a CRD that introduces a new default value will trigger a re-creation of all underlying pods.
Many alternatives are discussed in kubernetes/community#6764 to solve this, including having controllers only hash the fields they are interested in. This is problematic because over time as new fields are added, controllers may 'miss' these and therefore not trigger updates when the value is actually changed either.
Proposal
Adding a new marker that can be set on fields, e.g.
//+ kubebuilder:default:skip=true
which will causedefault
values to not be set in the generated sub-schema.The text was updated successfully, but these errors were encountered: