File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
pkg/controllers/resources/services Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ func (s *serviceSyncer) Sync(ctx *synccontext.SyncContext, event *synccontext.Sy
192
192
193
193
// update status
194
194
event .Virtual .Status = event .Host .Status
195
+ ensureLoadBalancerStatus (event .Virtual )
195
196
196
197
// bi-directional sync of annotations and labels
197
198
event .Virtual .Annotations , event .Host .Annotations = translate .AnnotationsBidirectionalUpdate (event , s .excludedAnnotations ... )
@@ -299,3 +300,17 @@ func TranslateServicePorts(ports []corev1.ServicePort) []corev1.ServicePort {
299
300
300
301
return retPorts
301
302
}
303
+
304
+ // ensureLoadBalancerStatus removes any LoadBalancer-related fields from the Service
305
+ // if it is of type ClusterIP.
306
+ //
307
+ // This is necessary to ensure consistency when syncing services from a virtual
308
+ // cluster to the host cluster. ClusterIP services should not carry LoadBalancer
309
+ // settings such as LoadBalancerIP or Status.LoadBalancer.Ingress, which are
310
+ // specific to LoadBalancer-type services and can cause incorrect behavior if retained.
311
+ func ensureLoadBalancerStatus (vObj * corev1.Service ) {
312
+ if vObj .Spec .Type != corev1 .ServiceTypeLoadBalancer {
313
+ vObj .Spec .LoadBalancerIP = ""
314
+ vObj .Status .LoadBalancer .Ingress = make ([]corev1.LoadBalancerIngress , 0 )
315
+ }
316
+ }
You can’t perform that action at this time.
0 commit comments