From 731fd77d6670d557a80269ed7f3fd90e47844a58 Mon Sep 17 00:00:00 2001 From: Andrey Inishev Date: Fri, 13 Sep 2019 16:33:07 +0700 Subject: [PATCH] add nodeSelector & tolerations --- pkg/apis/rabbitmq/v1/rabbitmq_types.go | 2 ++ pkg/apis/rabbitmq/v1/zz_generated.deepcopy.go | 32 +++++++++---------- .../rabbitmq/rabbitmq_controller.go | 2 ++ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/pkg/apis/rabbitmq/v1/rabbitmq_types.go b/pkg/apis/rabbitmq/v1/rabbitmq_types.go index 9431651..3c51a4d 100644 --- a/pkg/apis/rabbitmq/v1/rabbitmq_types.go +++ b/pkg/apis/rabbitmq/v1/rabbitmq_types.go @@ -120,6 +120,8 @@ type RabbitmqSpec struct { RabbitmqPrometheusImage string `json:"prometheus_image,omitempty"` RabbitmqAffinity *corev1.Affinity `json:"affinity,omitempty"` + NodeSelector map[string]string `json:"nodeSelector"` + Tolerations []corev1.Toleration `json:"tolerations"` RabbitmqUseServiceMonitor bool `json:"use_service_monitor,omitempty"` } diff --git a/pkg/apis/rabbitmq/v1/zz_generated.deepcopy.go b/pkg/apis/rabbitmq/v1/zz_generated.deepcopy.go index 31ecba2..e015986 100644 --- a/pkg/apis/rabbitmq/v1/zz_generated.deepcopy.go +++ b/pkg/apis/rabbitmq/v1/zz_generated.deepcopy.go @@ -1,22 +1,6 @@ // +build !ignore_autogenerated -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by deepcopy-gen. DO NOT EDIT. +// Code generated by operator-sdk. DO NOT EDIT. package v1 @@ -223,6 +207,20 @@ func (in *RabbitmqSpec) DeepCopyInto(out *RabbitmqSpec) { *out = new(corev1.Affinity) (*in).DeepCopyInto(*out) } + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]corev1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } diff --git a/pkg/controller/rabbitmq/rabbitmq_controller.go b/pkg/controller/rabbitmq/rabbitmq_controller.go index b37dd54..abaa13b 100644 --- a/pkg/controller/rabbitmq/rabbitmq_controller.go +++ b/pkg/controller/rabbitmq/rabbitmq_controller.go @@ -474,6 +474,8 @@ func newStatefulSet(cr *rabbitmqv1.Rabbitmq, secretNames secretResouces) *v1.Sta }, }, Containers: podContainers, + Tolerations: cr.Spec.Tolerations, + NodeSelector: cr.Spec.NodeSelector, Volumes: []corev1.Volume{ { Name: "rabbit-config",