|
7 | 7 | import org.slf4j.Logger;
|
8 | 8 | import org.slf4j.LoggerFactory;
|
9 | 9 |
|
| 10 | +import io.fabric8.kubernetes.api.model.ConfigMap; |
10 | 11 | import io.fabric8.kubernetes.api.model.HasMetadata;
|
| 12 | +import io.fabric8.kubernetes.api.model.Secret; |
11 | 13 | import io.fabric8.kubernetes.client.KubernetesClient;
|
12 | 14 | import io.fabric8.kubernetes.client.dsl.Resource;
|
13 | 15 | import io.javaoperatorsdk.operator.OperatorException;
|
@@ -38,6 +40,10 @@ public abstract class KubernetesDependentResource<R extends HasMetadata, P exten
|
38 | 40 |
|
39 | 41 | private static final Logger log = LoggerFactory.getLogger(KubernetesDependentResource.class);
|
40 | 42 |
|
| 43 | + public static final Set<Class<? extends HasMetadata>> DEFAULT_NON_SSA_RESOURCES = |
| 44 | + Set.of(ConfigMap.class, |
| 45 | + Secret.class); |
| 46 | + |
41 | 47 | protected KubernetesClient client;
|
42 | 48 | private final ResourceUpdaterMatcher<R> updaterMatcher;
|
43 | 49 | private final boolean garbageCollected = this instanceof GarbageCollected;
|
@@ -134,6 +140,7 @@ public R update(R actual, R desired, P primary, Context<P> context) {
|
134 | 140 | sanitizeDesired(desired, actual, primary, context);
|
135 | 141 | if (useSSA(context)) {
|
136 | 142 | updatedResource = prepare(desired, primary, "Updating")
|
| 143 | + .fieldManager(context.getControllerConfiguration().fieldManager()) |
137 | 144 | .fieldManager(context.getControllerConfiguration().fieldManager())
|
138 | 145 | .forceConflicts().serverSideApply();
|
139 | 146 | } else {
|
@@ -192,13 +199,18 @@ protected void addMetadata(boolean forMatch, R actualResource, final R target, P
|
192 | 199 | addReferenceHandlingMetadata(target, primary);
|
193 | 200 | }
|
194 | 201 |
|
195 |
| - protected void sanitizeDesired(R desired, R actual, P primary, Context<P> context) { |
196 |
| - DesiredResourceSanitizer.sanitizeDesired(desired, actual, primary, context); |
197 |
| - } |
| 202 | + protected void sanitizeDesired(R desired, R actual, P primary, Context<P> context) { |
| 203 | + DesiredResourceSanitizer.sanitizeDesired(desired, actual, primary, context, useSSA(context)); |
| 204 | + } |
198 | 205 |
|
199 |
| - private boolean useSSA(Context<P> context) { |
| 206 | + protected boolean useSSA(Context<P> context) { |
200 | 207 | Optional<Boolean> useSSAConfig =
|
201 | 208 | configuration().flatMap(KubernetesDependentResourceConfig::useSSA);
|
| 209 | + |
| 210 | + // don't use SSA for certain resources by default, only if explicitly overriden |
| 211 | + if (useSSAConfig.isEmpty() && DEFAULT_NON_SSA_RESOURCES.contains(resourceType())) { |
| 212 | + return false; |
| 213 | + } |
202 | 214 | return useSSAConfig.orElse(context.getControllerConfiguration().getConfigurationService()
|
203 | 215 | .ssaBasedCreateUpdateMatchForDependentResources());
|
204 | 216 | }
|
|
0 commit comments