From 38afa999d83cf68c2519651298e9da07ace73ad8 Mon Sep 17 00:00:00 2001 From: runkecheng <1131648942@qq.com> Date: Sat, 9 Oct 2021 10:11:19 +0800 Subject: [PATCH] cluster: Support extranet access service. #251 --- cluster/syncer/follower_service.go | 5 ++++- cluster/syncer/leader_service.go | 5 ++++- cluster/syncer/metrics_service.go | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cluster/syncer/follower_service.go b/cluster/syncer/follower_service.go index fa77b84f..03339593 100644 --- a/cluster/syncer/follower_service.go +++ b/cluster/syncer/follower_service.go @@ -41,7 +41,10 @@ func NewFollowerSVCSyncer(cli client.Client, c *cluster.Cluster) syncer.Interfac }, } return syncer.NewObjectSyncer("FollowerSVC", c.Unwrap(), service, cli, func() error { - service.Spec.Type = "ClusterIP" + // Allows to modify the service access method, the default is ClusterIP. + if service.Spec.Type == "" { + service.Spec.Type = "ClusterIP" + } service.Spec.Selector = c.GetSelectorLabels() service.Spec.Selector["role"] = "follower" service.Spec.Selector["healthy"] = "yes" diff --git a/cluster/syncer/leader_service.go b/cluster/syncer/leader_service.go index 31abb73c..3260f8e0 100644 --- a/cluster/syncer/leader_service.go +++ b/cluster/syncer/leader_service.go @@ -41,7 +41,10 @@ func NewLeaderSVCSyncer(cli client.Client, c *cluster.Cluster) syncer.Interface }, } return syncer.NewObjectSyncer("LeaderSVC", c.Unwrap(), service, cli, func() error { - service.Spec.Type = "ClusterIP" + // Allows to modify the service access method, the default is ClusterIP. + if service.Spec.Type == "" { + service.Spec.Type = "ClusterIP" + } service.Spec.Selector = c.GetSelectorLabels() service.Spec.Selector["role"] = "leader" diff --git a/cluster/syncer/metrics_service.go b/cluster/syncer/metrics_service.go index 466de1f5..110c2d3a 100644 --- a/cluster/syncer/metrics_service.go +++ b/cluster/syncer/metrics_service.go @@ -41,7 +41,10 @@ func NewMetricsSVCSyncer(cli client.Client, c *cluster.Cluster) syncer.Interface }, } return syncer.NewObjectSyncer("MetricsSVC", c.Unwrap(), service, cli, func() error { - service.Spec.Type = "ClusterIP" + // Allows to modify the service access method, the default is ClusterIP. + if service.Spec.Type == "" { + service.Spec.Type = "ClusterIP" + } service.Spec.Selector = c.GetSelectorLabels() if len(service.Spec.Ports) != 1 {