Browse Source

In 130 affinity

* add affinity spec to crd

* +
pull/10/head
Vladimir Smagin 1 year ago
committed by GitHub
parent
commit
885f51f898
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions
  1. +2
    -0
      pkg/apis/rabbitmq/v1/rabbitmq_types.go
  2. +5
    -0
      pkg/apis/rabbitmq/v1/zz_generated.deepcopy.go
  3. +7
    -0
      pkg/controller/rabbitmq/rabbitmq_controller.go

+ 2
- 0
pkg/apis/rabbitmq/v1/rabbitmq_types.go View File

@@ -119,6 +119,8 @@ type RabbitmqSpec struct {
RabbitmqPrometheusExporterPort int32 `json:"prometheus_exporter_port,omitempty"`
RabbitmqPrometheusImage string `json:"prometheus_image,omitempty"`

RabbitmqAffinity *corev1.Affinity `json:"affinity,omitempty"`

RabbitmqUseServiceMonitor bool `json:"use_service_monitor,omitempty"`
}



+ 5
- 0
pkg/apis/rabbitmq/v1/zz_generated.deepcopy.go View File

@@ -218,6 +218,11 @@ func (in *RabbitmqSpec) DeepCopyInto(out *RabbitmqSpec) {
(*out)[key] = val.DeepCopy()
}
}
if in.RabbitmqAffinity != nil {
in, out := &in.RabbitmqAffinity, &out.RabbitmqAffinity
*out = new(corev1.Affinity)
(*in).DeepCopyInto(*out)
}
return
}



+ 7
- 0
pkg/controller/rabbitmq/rabbitmq_controller.go View File

@@ -369,6 +369,12 @@ func newStatefulSet(cr *rabbitmqv1.Rabbitmq, secretNames secretResouces) *v1.Sta
// prepare containers for pod
podContainers := []corev1.Container{}

// check affinity rules
affinity := &corev1.Affinity{}
if cr.Spec.RabbitmqAffinity != nil {
affinity = cr.Spec.RabbitmqAffinity
}

// container with rabbitmq
rabbitmqContainer := corev1.Container{
Name: "rabbitmq",
@@ -440,6 +446,7 @@ func newStatefulSet(cr *rabbitmqv1.Rabbitmq, secretNames secretResouces) *v1.Sta
Annotations: returnAnnotations(cr),
},
Spec: corev1.PodSpec{
Affinity: affinity,
ServiceAccountName: cr.Spec.RabbitmqK8SServiceAccount,
InitContainers: []corev1.Container{
{


Loading…
Cancel
Save