v0.3.4
Enhancements
-
Support for server-side-apply: so far, updates to dependent objects happened through an replace/update (i.e. PUT) request. This approach has some drawbacks; most importantly, replace will revert all concurrent changes done on the object; while this is desirable for some kinds of changes( e..g somebody changing dependents manually by kubectl), there are other (legal) changes which should be preserved; such as changes done by HPA. Using server-side-apply PATCH (ssa) addresses this problem (see https://kubernetes.io/docs/reference/using-api/server-side-apply/). However, ssa never reverts foreign changes, if the declared manifest has no opinion about the corresponding fields. This means that manual changes (such as done by somebody using kubectl) might not get reverted. To overcome this, two server-side-apply modes are offered by component-operator-runtime:
ssa-merge: which is the standard server-side-apply behaviorssa-override: claim ownership of all fields owned by either kubectl or helm (identified by having field manager starting with the prefix 'kubectl' or 'helm'), and then, doing a regular server-side-apply.
-
Server-side-apply can be enabled on reconciler level by setting the according option field
UpdatePolicy:// ReconcilerOptions are creation options for a Reconciler. type ReconcilerOptions struct { // Whether namespaces are auto-created if missing. // If unspecified, true is assumed. CreateMissingNamespaces *bool // How to react if a dependent object exists but has no or a different owner. // If unspecified, AdoptionPolicyIfUnowned is assumed. // Can be overridden by annotation on object level. AdoptionPolicy *AdoptionPolicy // How to perform updates to dependent objects. // If unspecified, UpdatePolicyReplace is assumed. // Can be overridden by annotation on object level. UpdatePolicy *UpdatePolicy // Schemebuilder allows to define additional schemes to be made available in the // target client. SchemeBuilder types.SchemeBuilder }
to one of the constants
UpdatePolicySsaMergeorUpdatePolicySsaMerge, as defined in pkg/component. If this field is not specified in options, the default ofUpdatePolicyReplaceis assumed by the framework.
Furthermore, the update policy can be overridden on a per-object level, by setting the annotation
mycomponent-operator.example.io/update-policytossa-mergeorssa-override. -
Now, also the adoption policy can be overridden on a per-object level by setting the annotation
mycomponent-operator.example.io/adoption-policyto one ofnever,if-unowned,always. If not specified on an object level, the reconciler default counts, which in turn is defaulted ascomponent.AdoptionPolicyIfUnowned.