diff --git a/internal/infrastructure/kubernetes/resource/resource.go b/internal/infrastructure/kubernetes/resource/resource.go index 357b068c380..5bb2c962d3a 100644 --- a/internal/infrastructure/kubernetes/resource/resource.go +++ b/internal/infrastructure/kubernetes/resource/resource.go @@ -34,8 +34,9 @@ func ExpectedServiceSpec(serviceType *egcfgv1a1.ServiceType) corev1.ServiceSpec return serviceSpec } -// CompareSvc Only compare the selector and ports(not include nodePort) in case user have modified for some scene. +// CompareSvc Only compare the type, selector and ports(not include nodePort) in case user have modified for some scene. func CompareSvc(currentSvc, originalSvc *corev1.Service) bool { - return cmp.Equal(currentSvc.Spec.Selector, originalSvc.Spec.Selector) && + return cmp.Equal(currentSvc.Spec.Type, originalSvc.Spec.Type) && + cmp.Equal(currentSvc.Spec.Selector, originalSvc.Spec.Selector) && cmp.Equal(currentSvc.Spec.Ports, originalSvc.Spec.Ports, cmpopts.IgnoreFields(corev1.ServicePort{}, "NodePort")) } diff --git a/internal/infrastructure/kubernetes/resource/resource_test.go b/internal/infrastructure/kubernetes/resource/resource_test.go index ae4963e3bfb..1c122f830df 100644 --- a/internal/infrastructure/kubernetes/resource/resource_test.go +++ b/internal/infrastructure/kubernetes/resource/resource_test.go @@ -126,7 +126,7 @@ func TestCompareSvc(t *testing.T) { Selector: map[string]string{ "app": "my-app", }, - Type: "ClusterIP", + Type: "NodePort", }, }, }, {