caigy commented on a change in pull request #81:
URL: https://github.com/apache/rocketmq-operator/pull/81#discussion_r702390806



##########
File path: pkg/controller/broker/broker_controller.go
##########
@@ -375,14 +375,43 @@ func getBrokerName(broker *rocketmqv1alpha1.Broker, 
brokerGroupIndex int) string
 
 // getBrokerStatefulSet returns a broker StatefulSet object
 func (r *ReconcileBroker) getBrokerStatefulSet(broker 
*rocketmqv1alpha1.Broker, brokerGroupIndex int, replicaIndex int) 
*appsv1.StatefulSet {
-       ls := labelsForBroker(broker.Name)
+       ls := labelsForBrokerWithRole(broker.Name,replicaIndex)
        var a int32 = 1
        var c = &a
        var statefulSetName string
+       var podAntiAffinity *corev1.PodAntiAffinity
        if replicaIndex == 0 {
                statefulSetName = broker.Name + "-" + 
strconv.Itoa(brokerGroupIndex) + "-master"
+               podAntiAffinity = &corev1.PodAntiAffinity{
+                       RequiredDuringSchedulingIgnoredDuringExecution:  
[]corev1.PodAffinityTerm{corev1.PodAffinityTerm{
+                               TopologyKey: "kubernetes.io/hostname",
+                               LabelSelector: &metav1.LabelSelector{
+                                       MatchLabels: ls,
+                                       },
+                               }},
+                       PreferredDuringSchedulingIgnoredDuringExecution: 
[]corev1.WeightedPodAffinityTerm{corev1.WeightedPodAffinityTerm{
+                               Weight: 100,
+                               PodAffinityTerm: corev1.PodAffinityTerm{
+                                       TopologyKey: "kubernetes.io/hostname",
+                                       LabelSelector: &metav1.LabelSelector{
+                                               MatchLabels: 
labelsForBroker(broker.Name),
+                                       },
+                               },
+                       }},
+               }

Review comment:
       You'b better open another PR to do it, because this is obviously 
unrelated to this issue.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to