Description
Matching in dependent resources with Kubernetes objects is quite complex problem. When we SSA based resource create and update was introduced, we introduced also the SSABasedGenericKubernetesResourceMatcher, where the expectation was that this will cover nicely majority of cases (definitely not all of them).
Having some issues with SSA based matching was expected, there were obvious cases which are problematic. But there are always fallback strategies, either GenericKubernetesResourceMatcher or just implemeting a custom matcher.
This issue is to give an overview of the current problems and agree on strategy how to proceed with the SSA based matcher.
Problems
-
Most of the problem we see is actually about how Kubernetes post processes resources after are applied, typical case (what is actually a bug in K8S, when
stringData
is converted todata
in aSecret
, but in the managed fields stillstringData
is referenced. See: Refinements to SSA matching #2028 -
Other problem is, for example with default values in Ingress, see: Repeated server side apply creates additional revisions kubernetes/kubernetes#118519 (comment) . When the empty string value is removed, while in desired empty string is expected.
-
Third example when, some values are added to the resource, but mainly some fields are removed ( since the feature what it is used for is behind a feature flag gate in K8S. See: NullPointerException in SSABasedGenericKubernetesResourceMatcher #2032 and related integration test where it actually works. Note that in this case typically in spec part status is added to volume claim template:
status:
phase: pending
Solutions
These problem are quite specific to those resources, but most of the cases we can just solve but adjust the desired resource. So if we fill in the default values (or remove the empty string for example, or the fields behind feature gate), the problem disappears. See in: #2037
So either:
-
we delegate the problem to the users, that we say that please fill in the default values (or remove), and the matching will work. In case of
stringData
we can simply say that "this is a convenience feature, please don't use it". -
the framework could add (or make it easy to add) corrections, so if it seems that some known default values are missing, like mentioned above, it will fill in the default values. This can happen either in matching phase or as post processing the desired resource. The problem with this approach is that the implementation will end up reproducing K8S API Server logic, that might be complex (and might change based on the k8s version?)