Skip to content

Commit

Permalink
Use prod config for rabbitmq
Browse files Browse the repository at this point in the history
  • Loading branch information
olliewalsh committed Sep 19, 2024
1 parent aadcf92 commit 477f26e
Showing 1 changed file with 38 additions and 12 deletions.
50 changes: 38 additions & 12 deletions pkg/openstack/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,24 @@ func reconcileRabbitMQ(
},
InitContainers: []corev1.Container{
{Name: "setup-container", SecurityContext: &corev1.SecurityContext{}}},
TopologySpreadConstraints: []corev1.TopologySpreadConstraint{
{
MaxSkew: 1,
TopologyKey: "topology.kubernetes.io/zone",
WhenUnsatisfiable: corev1.DoNotSchedule,
LabelSelector: &metav1.LabelSelector{
MatchExpressions: []metav1.LabelSelectorRequirement{
{
Key: "app.kubernetes.io/name",
Operator: metav1.LabelSelectorOpIn,
Values: []string{
rabbitmq.Name,
},
},
},
},
},
},
},
},
},
Expand Down Expand Up @@ -334,29 +352,37 @@ func reconcileRabbitMQ(
// https://github.com/rabbitmq/cluster-operator/blob/11361d4201a55f457da7c1a2f69e75b2b0cfd069/docs/examples/pod-anti-affinity/rabbitmq.yaml
rabbitmq.Spec.Affinity = &corev1.Affinity{
PodAntiAffinity: &corev1.PodAntiAffinity{
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
{
Weight: 100,
PodAffinityTerm: corev1.PodAffinityTerm{
LabelSelector: &metav1.LabelSelector{
MatchExpressions: []metav1.LabelSelectorRequirement{
{
Key: "app.kubernetes.io/name",
Operator: metav1.LabelSelectorOpIn,
Values: []string{
"pod-anti-affinity",
},
LabelSelector: &metav1.LabelSelector{
MatchExpressions: []metav1.LabelSelectorRequirement{
{
Key: "app.kubernetes.io/name",
Operator: metav1.LabelSelectorOpIn,
Values: []string{
rabbitmq.Name,
},
},
},
TopologyKey: "kubernetes.io/hostname",
},
TopologyKey: "kubernetes.io/hostname",
},
},
},
}
}

// TODO:
// apiVersion: policy/v1
// kind: PodDisruptionBudget
// metadata:
// name: production-ready-rabbitmq
// spec:
// maxUnavailable: 1
// selector:
// matchLabels:
// app.kubernetes.io/name: <rabbitmq.Name>

if rabbitmq.Spec.Persistence.StorageClassName == nil {
Log.Info(fmt.Sprintf("Setting StorageClassName: " + instance.Spec.StorageClass))
rabbitmq.Spec.Persistence.StorageClassName = &instance.Spec.StorageClass
Expand Down

0 comments on commit 477f26e

Please sign in to comment.