@@ -160,7 +160,7 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
160
160
ports := []core.ServicePort {CreateServerServicePort ()}
161
161
// Service should exists
162
162
if ! ok {
163
- s := r .createService (name , apiObject .GetNamespace (), spec . CommunicationMethod . ServiceClusterIP (), spec . CommunicationMethod . ServiceType () , false , apiObject .AsOwner (), ports , selector )
163
+ s := r .createService (name , apiObject .GetNamespace (), "" , core . ServiceTypeClusterIP , false , apiObject .AsOwner (), ports , selector )
164
164
165
165
err := globals .GetGlobalTimeouts ().Kubernetes ().RunWithTimeout (ctx , func (ctxChild context.Context ) error {
166
166
_ , err := svcs .Create (ctxChild , s , meta.CreateOptions {})
@@ -175,14 +175,26 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
175
175
reconcileRequired .Required ()
176
176
continue
177
177
} else {
178
- if _ , changed , err := patcher .Patcher [* core.Service ](ctx , svcs , s , meta.PatchOptions {},
179
- patcher .PatchServicePorts (ports ),
180
- patcher .PatchServiceSelector (selector ),
181
- patcher .PatchServicePublishNotReadyAddresses (false ),
182
- patcher .PatchServiceType (spec .CommunicationMethod .ServiceType ())); err != nil {
183
- return err
184
- } else if changed {
185
- reconcileRequired .Required ()
178
+ if s .Spec .ClusterIP == core .ClusterIPNone {
179
+ // Recreation required
180
+ if err := globals .GetGlobalTimeouts ().Kubernetes ().RunWithTimeout (ctx , func (ctxChild context.Context ) error {
181
+ return svcs .Delete (ctxChild , s .GetName (), meta.DeleteOptions {})
182
+ }); err != nil {
183
+ if ! kerrors .IsNotFound (err ) {
184
+ return err
185
+ }
186
+ reconcileRequired .Required ()
187
+ }
188
+ } else {
189
+ if _ , changed , err := patcher .Patcher [* core.Service ](ctx , svcs , s , meta.PatchOptions {},
190
+ patcher .PatchServicePorts (ports ),
191
+ patcher .PatchServiceSelector (selector ),
192
+ patcher .PatchServicePublishNotReadyAddresses (false ),
193
+ patcher .PatchServiceType (core .ServiceTypeClusterIP )); err != nil {
194
+ return err
195
+ } else if changed {
196
+ reconcileRequired .Required ()
197
+ }
186
198
}
187
199
}
188
200
}
0 commit comments