overstep123 commented on a change in pull request #81:
URL: https://github.com/apache/rocketmq-operator/pull/81#discussion_r700984944
##########
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:
I have no idea why the nodeAffinity is needed. But the podAntiAffinity
is sure needed. Because I don't want to see that the whole cluster(maybe multi
master borker) become unwritable when all the master broker are assigned to the
same node and the node is down. This situation will be worse if the kubernetes
can't new the master pod in time.
--
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]