diff --git a/api/bases/telemetry.openstack.org_autoscalings.yaml b/api/bases/telemetry.openstack.org_autoscalings.yaml index 66b34e53..b7341114 100644 --- a/api/bases/telemetry.openstack.org_autoscalings.yaml +++ b/api/bases/telemetry.openstack.org_autoscalings.yaml @@ -107,6 +107,12 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to target subset of worker nodes running + this service + type: object notifierImage: type: string override: diff --git a/api/bases/telemetry.openstack.org_ceilometers.yaml b/api/bases/telemetry.openstack.org_ceilometers.yaml index 94078042..654b4e56 100644 --- a/api/bases/telemetry.openstack.org_ceilometers.yaml +++ b/api/bases/telemetry.openstack.org_ceilometers.yaml @@ -153,6 +153,12 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to target subset of worker nodes running + this service + type: object notificationImage: type: string passwordSelector: diff --git a/api/bases/telemetry.openstack.org_telemetries.yaml b/api/bases/telemetry.openstack.org_telemetries.yaml index 4b282a46..39ca4c14 100644 --- a/api/bases/telemetry.openstack.org_telemetries.yaml +++ b/api/bases/telemetry.openstack.org_telemetries.yaml @@ -110,6 +110,12 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to target subset of worker nodes + running this service + type: object notifierImage: type: string override: @@ -474,6 +480,12 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to target subset of worker nodes running + this service + type: object notificationImage: type: string passwordSelector: @@ -1829,6 +1841,12 @@ spec: type: string type: object type: object + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to target subset of worker nodes running + this service + type: object type: object status: description: TelemetryStatus defines the observed state of Telemetry diff --git a/api/v1beta1/autoscaling_types.go b/api/v1beta1/autoscaling_types.go index c1c1f9de..bf5b7589 100644 --- a/api/v1beta1/autoscaling_types.go +++ b/api/v1beta1/autoscaling_types.go @@ -127,6 +127,10 @@ type AodhCore struct { // +operator-sdk:csv:customresourcedefinitions:type=spec // TLS - Parameters related to the TLS TLS tls.API `json:"tls,omitempty"` + + // +kubebuilder:validation:Optional + // NodeSelector to target subset of worker nodes running this service + NodeSelector *map[string]string `json:"nodeSelector,omitempty"` } // APIOverrideSpec to override the generated manifest of several child resources. diff --git a/api/v1beta1/ceilometer_types.go b/api/v1beta1/ceilometer_types.go index d596204a..37150e2f 100644 --- a/api/v1beta1/ceilometer_types.go +++ b/api/v1beta1/ceilometer_types.go @@ -117,6 +117,10 @@ type CeilometerSpecCore struct { // +operator-sdk:csv:customresourcedefinitions:type=spec // KSMTLS - Parameters related to the TLS for kube-state-metrics KSMTLS tls.SimpleService `json:"ksmTls,omitempty"` + + // +kubebuilder:validation:Optional + // NodeSelector to target subset of worker nodes running this service + NodeSelector *map[string]string `json:"nodeSelector,omitempty"` } // CeilometerStatus defines the observed state of Ceilometer diff --git a/api/v1beta1/telemetry_types.go b/api/v1beta1/telemetry_types.go index 44e00183..78727359 100644 --- a/api/v1beta1/telemetry_types.go +++ b/api/v1beta1/telemetry_types.go @@ -71,6 +71,10 @@ type TelemetrySpecBase struct { // +kubebuilder:validation:Optional // Logging - Parameters related to the logging Logging LoggingSection `json:"logging,omitempty"` + + // +kubebuilder:validation:Optional + // NodeSelector to target subset of worker nodes running this service + NodeSelector *map[string]string `json:"nodeSelector,omitempty"` } // CeilometerSection defines the desired state of the ceilometer service diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 7e55af6d..cc09886d 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -86,6 +86,17 @@ func (in *AodhCore) DeepCopyInto(out *AodhCore) { } in.Override.DeepCopyInto(&out.Override) in.TLS.DeepCopyInto(&out.TLS) + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = new(map[string]string) + if **in != nil { + in, out := *in, *out + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AodhCore. @@ -460,6 +471,17 @@ func (in *CeilometerSpecCore) DeepCopyInto(out *CeilometerSpecCore) { } in.TLS.DeepCopyInto(&out.TLS) in.KSMTLS.DeepCopyInto(&out.KSMTLS) + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = new(map[string]string) + if **in != nil { + in, out := *in, *out + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CeilometerSpecCore. @@ -963,6 +985,17 @@ func (in *TelemetrySpecBase) DeepCopyInto(out *TelemetrySpecBase) { *out = *in in.MetricStorage.DeepCopyInto(&out.MetricStorage) in.Logging.DeepCopyInto(&out.Logging) + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = new(map[string]string) + if **in != nil { + in, out := *in, *out + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TelemetrySpecBase. diff --git a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml index 66b34e53..b7341114 100644 --- a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml +++ b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml @@ -107,6 +107,12 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to target subset of worker nodes running + this service + type: object notifierImage: type: string override: diff --git a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml index 94078042..654b4e56 100644 --- a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml +++ b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml @@ -153,6 +153,12 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to target subset of worker nodes running + this service + type: object notificationImage: type: string passwordSelector: diff --git a/config/crd/bases/telemetry.openstack.org_telemetries.yaml b/config/crd/bases/telemetry.openstack.org_telemetries.yaml index 4b282a46..39ca4c14 100644 --- a/config/crd/bases/telemetry.openstack.org_telemetries.yaml +++ b/config/crd/bases/telemetry.openstack.org_telemetries.yaml @@ -110,6 +110,12 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to target subset of worker nodes + running this service + type: object notifierImage: type: string override: @@ -474,6 +480,12 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to target subset of worker nodes running + this service + type: object notificationImage: type: string passwordSelector: @@ -1829,6 +1841,12 @@ spec: type: string type: object type: object + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to target subset of worker nodes running + this service + type: object type: object status: description: TelemetryStatus defines the observed state of Telemetry diff --git a/controllers/telemetry_controller.go b/controllers/telemetry_controller.go index 06170a6d..fc9d881c 100644 --- a/controllers/telemetry_controller.go +++ b/controllers/telemetry_controller.go @@ -251,6 +251,10 @@ func (r TelemetryReconciler) reconcileCeilometer(ctx context.Context, instance * return ctrl.Result{}, nil } + if instance.Spec.Ceilometer.NodeSelector == nil { + instance.Spec.Ceilometer.NodeSelector = instance.Spec.NodeSelector + } + helper.GetLogger().Info("Reconciling Ceilometer", ceilometerNamespaceLabel, instance.Namespace, ceilometerNameLabel, ceilometer.ServiceName) op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), ceilometerInstance, func() error { instance.Spec.Ceilometer.CeilometerSpec.DeepCopyInto(&ceilometerInstance.Spec) @@ -328,6 +332,10 @@ func (r TelemetryReconciler) reconcileAutoscaling(ctx context.Context, instance return ctrl.Result{}, nil } + if instance.Spec.Autoscaling.Aodh.NodeSelector == nil { + instance.Spec.Autoscaling.Aodh.NodeSelector = instance.Spec.NodeSelector + } + helper.GetLogger().Info("Reconciling Autoscaling", autoscalingNamespaceLabel, instance.Namespace, autoscalingNameLabel, autoscalingName) op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), autoscalingInstance, func() error { instance.Spec.Autoscaling.AutoscalingSpec.DeepCopyInto(&autoscalingInstance.Spec) diff --git a/pkg/autoscaling/aodh_statefulset.go b/pkg/autoscaling/aodh_statefulset.go index 58a27b29..ba3e8191 100644 --- a/pkg/autoscaling/aodh_statefulset.go +++ b/pkg/autoscaling/aodh_statefulset.go @@ -200,6 +200,10 @@ func AodhStatefulSet( }, } + if instance.Spec.Aodh.NodeSelector != nil { + pod.Spec.NodeSelector = *instance.Spec.Aodh.NodeSelector + } + statefulset := &appsv1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ Name: ServiceName, diff --git a/pkg/autoscaling/dbsync.go b/pkg/autoscaling/dbsync.go index 22dd34f5..4cdce8a6 100644 --- a/pkg/autoscaling/dbsync.go +++ b/pkg/autoscaling/dbsync.go @@ -92,5 +92,9 @@ func DbSyncJob(instance *autoscalingv1beta1.Autoscaling, labels map[string]strin }, } + if instance.Spec.Aodh.NodeSelector != nil { + job.Spec.Template.Spec.NodeSelector = *instance.Spec.Aodh.NodeSelector + } + return job } diff --git a/pkg/availability/statefulset.go b/pkg/availability/statefulset.go index b8783152..5e8942e8 100644 --- a/pkg/availability/statefulset.go +++ b/pkg/availability/statefulset.go @@ -170,5 +170,9 @@ func KSMStatefulSet( }, } + if instance.Spec.NodeSelector != nil { + ss.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector + } + return ss, nil } diff --git a/pkg/ceilometer/statefulset.go b/pkg/ceilometer/statefulset.go index 8c1e9302..0c7c0a0e 100644 --- a/pkg/ceilometer/statefulset.go +++ b/pkg/ceilometer/statefulset.go @@ -183,6 +183,10 @@ func StatefulSet( }, } + if instance.Spec.NodeSelector != nil { + pod.Spec.NodeSelector = *instance.Spec.NodeSelector + } + statefulset := &appsv1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ Name: ServiceName,