16
16
import io .fabric8 .kubernetes .api .model .apps .Deployment ;
17
17
import io .fabric8 .kubernetes .api .model .networking .v1 .Ingress ;
18
18
import io .fabric8 .kubernetes .client .KubernetesClient ;
19
+ import io .fabric8 .kubernetes .client .dsl .Replaceable ;
19
20
import io .javaoperatorsdk .operator .ReconcilerUtils ;
20
21
import io .javaoperatorsdk .operator .api .config .informer .InformerConfiguration ;
21
22
import io .javaoperatorsdk .operator .api .reconciler .Context ;
@@ -107,7 +108,7 @@ public UpdateControl<WebPage> reconcile(WebPage webPage, Context<WebPage> contex
107
108
desiredHtmlConfigMap .getMetadata ().getName (),
108
109
ns );
109
110
var res = kubernetesClient .configMaps ().inNamespace (ns ).resource (desiredHtmlConfigMap )
110
- .createOrReplace ( );
111
+ .createOr ( Replaceable :: update );
111
112
log .debug ("Updated config map: {}" , res );
112
113
}
113
114
@@ -118,7 +119,7 @@ public UpdateControl<WebPage> reconcile(WebPage webPage, Context<WebPage> contex
118
119
desiredDeployment .getMetadata ().getName (),
119
120
ns );
120
121
kubernetesClient .apps ().deployments ().inNamespace (ns ).resource (desiredDeployment )
121
- .createOrReplace ( );
122
+ .createOr ( Replaceable :: update );
122
123
}
123
124
124
125
var existingService = context .getSecondaryResource (Service .class ).orElse (null );
@@ -127,14 +128,15 @@ public UpdateControl<WebPage> reconcile(WebPage webPage, Context<WebPage> contex
127
128
"Creating or updating Deployment {} in {}" ,
128
129
desiredDeployment .getMetadata ().getName (),
129
130
ns );
130
- kubernetesClient .services ().inNamespace (ns ).resource (desiredService ).createOrReplace ();
131
+ kubernetesClient .services ().inNamespace (ns ).resource (desiredService )
132
+ .createOr (Replaceable ::update );
131
133
}
132
134
133
135
var existingIngress = context .getSecondaryResource (Ingress .class );
134
136
if (Boolean .TRUE .equals (webPage .getSpec ().getExposed ())) {
135
137
var desiredIngress = makeDesiredIngress (webPage );
136
138
if (existingIngress .isEmpty () || !match (desiredIngress , existingIngress .get ())) {
137
- kubernetesClient .resource (desiredIngress ).inNamespace (ns ).createOrReplace ( );
139
+ kubernetesClient .resource (desiredIngress ).inNamespace (ns ).createOr ( Replaceable :: update );
138
140
}
139
141
} else
140
142
existingIngress .ifPresent (
@@ -150,7 +152,7 @@ public UpdateControl<WebPage> reconcile(WebPage webPage, Context<WebPage> contex
150
152
kubernetesClient .pods ().inNamespace (ns ).withLabel ("app" , deploymentName (webPage )).delete ();
151
153
}
152
154
webPage .setStatus (createStatus (desiredHtmlConfigMap .getMetadata ().getName ()));
153
- return UpdateControl .updateStatus (webPage );
155
+ return UpdateControl .patchStatus (webPage );
154
156
}
155
157
156
158
private boolean match (Ingress desiredIngress , Ingress existingIngress ) {
0 commit comments