From cbd151aa2aa6c3e768a4903c7774d5d7ee9f4170 Mon Sep 17 00:00:00 2001 From: Howard Lau Date: Fri, 30 Oct 2020 07:14:24 +0000 Subject: [PATCH] fix service Signed-off-by: Howard Lau --- controllers/controller_master_service.go | 16 ++++++++++++++++ controllers/controller_volume.go | 2 +- controllers/controller_volume_service.go | 24 +++++++++++++++++++++--- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/controllers/controller_master_service.go b/controllers/controller_master_service.go index cd04c17..4e6b98f 100644 --- a/controllers/controller_master_service.go +++ b/controllers/controller_master_service.go @@ -77,5 +77,21 @@ func (r *SeaweedReconciler) createMasterService(m *seaweedv1.Seaweed) *corev1.Se }, } + if m.Spec.Master.Service != nil { + svcSpec := m.Spec.Master.Service + dep.Annotations = copyAnnotations(svcSpec.Annotations) + + if svcSpec.Type != "" { + dep.Spec.Type = svcSpec.Type + } + + if svcSpec.ClusterIP != nil { + dep.Spec.ClusterIP = *svcSpec.ClusterIP + } + + if svcSpec.LoadBalancerIP != nil { + dep.Spec.LoadBalancerIP = *svcSpec.LoadBalancerIP + } + } return dep } diff --git a/controllers/controller_volume.go b/controllers/controller_volume.go index 5811a3e..05e3db6 100644 --- a/controllers/controller_volume.go +++ b/controllers/controller_volume.go @@ -20,7 +20,7 @@ func (r *SeaweedReconciler) ensureVolumeServers(seaweedCR *seaweedv1.Seaweed) (d return } - if done, result, err = r.ensureVolumeServerStatefulSet(seaweedCR); done { + if done, result, err = r.ensureVolumeServerService(seaweedCR); done { return } diff --git a/controllers/controller_volume_service.go b/controllers/controller_volume_service.go index 7b4985b..57a78e0 100644 --- a/controllers/controller_volume_service.go +++ b/controllers/controller_volume_service.go @@ -25,13 +25,13 @@ func (r *SeaweedReconciler) createVolumeServerPeerService(m *seaweedv1.Seaweed) PublishNotReadyAddresses: true, Ports: []corev1.ServicePort{ { - Name: "swfs-volume", + Name: "volume-http", Protocol: corev1.Protocol("TCP"), Port: seaweedv1.VolumeHTTPPort, TargetPort: intstr.FromInt(seaweedv1.VolumeHTTPPort), }, { - Name: "swfs-volume-grpc", + Name: "volume-grpc", Protocol: corev1.Protocol("TCP"), Port: seaweedv1.VolumeGRPCPort, TargetPort: intstr.FromInt(seaweedv1.VolumeGRPCPort), @@ -58,7 +58,7 @@ func (r *SeaweedReconciler) createVolumeServerService(m *seaweedv1.Seaweed) *cor PublishNotReadyAddresses: true, Ports: []corev1.ServicePort{ { - Name: "volume", + Name: "volume-http", Protocol: corev1.Protocol("TCP"), Port: seaweedv1.VolumeHTTPPort, TargetPort: intstr.FromInt(seaweedv1.VolumeHTTPPort), @@ -73,5 +73,23 @@ func (r *SeaweedReconciler) createVolumeServerService(m *seaweedv1.Seaweed) *cor Selector: labels, }, } + + if m.Spec.Volume.Service != nil { + svcSpec := m.Spec.Volume.Service + dep.Annotations = copyAnnotations(svcSpec.Annotations) + + if svcSpec.Type != "" { + dep.Spec.Type = svcSpec.Type + } + + if svcSpec.ClusterIP != nil { + dep.Spec.ClusterIP = *svcSpec.ClusterIP + } + + if svcSpec.LoadBalancerIP != nil { + dep.Spec.LoadBalancerIP = *svcSpec.LoadBalancerIP + } + } + return dep }