Skip to content

Commit 7b1b693

Browse files
committed
handle new dual-stack field ClusterIPs
also fix propagation of headless services, and (rare) updates of services when type is changed to ExternalName Signed-off-by: adrienjt <[email protected]>
1 parent ebb0d7e commit 7b1b693

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pkg/controllers/follow/service/controller.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,12 @@ func (r reconciler) Handle(obj interface{}) (requeueAfter *time.Duration, err er
197197
}
198198
} else {
199199
spec := svc.Spec.DeepCopy()
200-
spec.ClusterIP = remoteSvc.Spec.ClusterIP
200+
if spec.Type != corev1.ServiceTypeExternalName {
201+
// ClusterIP is controlled locally.
202+
// However, if the type field is changed to ExternalName, ClusterIP must be reset.
203+
spec.ClusterIP = remoteSvc.Spec.ClusterIP // ""
204+
spec.ClusterIPs = remoteSvc.Spec.ClusterIPs // nil
205+
}
201206
if !reflect.DeepEqual(&remoteSvc.Spec, spec) {
202207
remoteCopy := remoteSvc.DeepCopy()
203208
remoteCopy.Spec = *spec.DeepCopy()
@@ -285,6 +290,11 @@ func makeRemoteService(actual *corev1.Service) *corev1.Service {
285290
gold.Annotations[common.AnnotationKeyIsDelegate] = ""
286291
controller.AddRemoteControllerReference(gold, actual)
287292
gold.Spec = *actual.Spec.DeepCopy()
288-
gold.Spec.ClusterIP = "" // cluster IP given by each cluster (not really a top-level spec)
293+
if actual.Spec.ClusterIP != corev1.ClusterIPNone {
294+
// cluster IP given by each cluster (not really a top-level spec)
295+
// but don't empty for headless services (keep None)
296+
gold.Spec.ClusterIP = ""
297+
gold.Spec.ClusterIPs = nil
298+
}
289299
return gold
290300
}

0 commit comments

Comments
 (0)