diff --git a/mysqlcluster/syncer/follower_service.go b/mysqlcluster/syncer/follower_service.go index 37a62f6f1..6960c00c7 100644 --- a/mysqlcluster/syncer/follower_service.go +++ b/mysqlcluster/syncer/follower_service.go @@ -48,7 +48,7 @@ func NewFollowerSVCSyncer(cli client.Client, c *mysqlcluster.MysqlCluster) synce service.Spec.Type = "ClusterIP" } service.Spec.Selector = c.GetSelectorLabels() - service.Spec.Selector["role"] = "follower" + service.Spec.Selector["role"] = string(utils.Follower) service.Spec.Selector["healthy"] = "yes" if len(service.Spec.Ports) != 2 { diff --git a/mysqlcluster/syncer/leader_service.go b/mysqlcluster/syncer/leader_service.go index 1251e19cd..2bae1904d 100644 --- a/mysqlcluster/syncer/leader_service.go +++ b/mysqlcluster/syncer/leader_service.go @@ -48,7 +48,7 @@ func NewLeaderSVCSyncer(cli client.Client, c *mysqlcluster.MysqlCluster) syncer. service.Spec.Type = "ClusterIP" } service.Spec.Selector = c.GetSelectorLabels() - service.Spec.Selector["role"] = "leader" + service.Spec.Selector["role"] = string(utils.Leader) if len(service.Spec.Ports) != 2 { service.Spec.Ports = make([]corev1.ServicePort, 2) diff --git a/mysqlcluster/syncer/status.go b/mysqlcluster/syncer/status.go index 13d93908e..599045928 100644 --- a/mysqlcluster/syncer/status.go +++ b/mysqlcluster/syncer/status.go @@ -375,6 +375,7 @@ func (s *StatusSyncer) setPodHealthy(ctx context.Context, pod *corev1.Pod, node if pod.Labels["healthy"] != healthy { pod.Labels["healthy"] = healthy + pod.Labels["role"] = node.RaftStatus.Role if err := s.cli.Update(ctx, pod); client.IgnoreNotFound(err) != nil { return err }