Skip to content

Commit

Permalink
bugfix: set cluster-ip when mapping host to vCluster service
Browse files Browse the repository at this point in the history
  • Loading branch information
maheshbaliga committed Dec 11, 2024
1 parent fa41bde commit 1ae8ac9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/controllers/servicesync/servicesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,17 @@ func (e *ServiceSyncer) syncServiceAndEndpoints(ctx context.Context, fromService
},
},
Spec: corev1.ServiceSpec{
Ports: fromService.Spec.Ports,
ClusterIP: corev1.ClusterIPNone,
Ports: fromService.Spec.Ports,
},
}

// Check if ClusterIP is not "None"
if fromService.Spec.ClusterIP != corev1.ClusterIPNone {
toService.Spec.ClusterIP = fromService.Spec.ClusterIP
} else {
toService.Spec.ClusterIP = corev1.ClusterIPNone
}

if e.IsVirtualToHostSyncer {
e.Log.Infof("Add owner reference to host target service %s", to.Name)
toService.OwnerReferences = translate.GetOwnerReference(nil)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/servicesync/servicesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func testMapping(ctx context.Context, fromClient kubernetes.Interface, fromNames
framework.ExpectEqual(toService.Spec.Selector[translate.NamespaceLabel], fromNamespace)
framework.ExpectEqual(toService.Spec.Selector[translate.MarkerLabel], translate.VClusterName)
framework.ExpectEqual(toService.Spec.Selector[translate.HostLabel("test")], "test")
framework.ExpectEqual(toService.Spec.ClusterIP, fromService.Spec.ClusterIP)
}

// check service deletion
Expand Down

0 comments on commit 1ae8ac9

Please sign in to comment.