From 6212e9c684243444800d327855372a4599804778 Mon Sep 17 00:00:00 2001 From: Vee Zhang <14001308+veezhang@users.noreply.github.com> Date: Tue, 8 Mar 2022 17:58:52 +0800 Subject: [PATCH] fix: #113 --- apis/apps/v1alpha1/nebulacluster_common.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apis/apps/v1alpha1/nebulacluster_common.go b/apis/apps/v1alpha1/nebulacluster_common.go index ac4f13bc..7af01470 100644 --- a/apis/apps/v1alpha1/nebulacluster_common.go +++ b/apis/apps/v1alpha1/nebulacluster_common.go @@ -410,14 +410,16 @@ func generateService(c NebulaClusterComponentter) *corev1.Service { }, } + serviceSpec := c.GetServiceSpec() + if serviceSpec != nil && len(serviceSpec.Annotations) > 0 { + service.Annotations = serviceSpec.Annotations + } + if c.IsHeadlessService() { service.Spec.ClusterIP = corev1.ClusterIPNone service.Spec.PublishNotReadyAddresses = true - } else { - serviceSpec := c.GetServiceSpec() - if serviceSpec != nil && serviceSpec.ClusterIP != nil { - service.Spec.ClusterIP = *serviceSpec.ClusterIP - } + } else if serviceSpec != nil && serviceSpec.ClusterIP != nil { + service.Spec.ClusterIP = *serviceSpec.ClusterIP } return service