diff --git a/api/v1beta1/dorisinitializer_types.go b/api/v1beta1/dorisinitializer_types.go index cfb9de0..396fd3a 100644 --- a/api/v1beta1/dorisinitializer_types.go +++ b/api/v1beta1/dorisinitializer_types.go @@ -90,6 +90,10 @@ type DorisInitializerSpec struct { // Tolerations of the Doris initializer Pod // +optional Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + + // NodeSelector of the Doris initializer Pod. + // +optional + NodeSelector map[string]string `json:"nodeSelector,omitempty"` } // DorisInitializerStatus defines the observed state of DorisInitializer diff --git a/api/v1beta1/dorismonitor_types.go b/api/v1beta1/dorismonitor_types.go index 18cf17f..cf68510 100644 --- a/api/v1beta1/dorismonitor_types.go +++ b/api/v1beta1/dorismonitor_types.go @@ -77,6 +77,10 @@ type DorisMonitorSpec struct { // Specify a Service Account // +optional ServiceAccount string `json:"serviceAccount,omitempty"` + + // NodeSelector of the Doris monitor components. + // +optional + NodeSelector map[string]string `json:"nodeSelector,omitempty"` } // PrometheusSpec defines the desired state of Prometheus @@ -98,6 +102,9 @@ type PrometheusSpec struct { // +optional StorageClassName string `json:"storageClassName,omitempty"` + + // +optional + NodeSelector map[string]string `json:"nodeSelector,omitempty"` } // GrafanaSpec defines the desired state of Grafana @@ -122,6 +129,9 @@ type GrafanaSpec struct { // +optional StorageClassName string `json:"storageClassName,omitempty"` + + // +optional + NodeSelector map[string]string `json:"nodeSelector,omitempty"` } // LokiSpec defines the desired state of Loki @@ -139,6 +149,9 @@ type LokiSpec struct { // +optional StorageClassName string `json:"storageClassName,omitempty"` + + // +optional + NodeSelector map[string]string `json:"nodeSelector,omitempty"` } // PromtailSpec defines the desired state of Promtail @@ -162,7 +175,7 @@ type MonitorServiceSpec struct { HttpPort *int32 `json:"httpPort,omitempty"` // ExternalTrafficPolicy of the service - // Optional: Defaults to omitted + // Optional: Defaults to nil // +optional ExternalTrafficPolicy *corev1.ServiceExternalTrafficPolicyType `json:"externalTrafficPolicy,omitempty"` } diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index a88562a..cb46652 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -776,6 +776,13 @@ func (in *DorisInitializerSpec) DeepCopyInto(out *DorisInitializerSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + 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 + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DorisInitializerSpec. @@ -964,6 +971,13 @@ func (in *DorisMonitorSpec) DeepCopyInto(out *DorisMonitorSpec) { *out = new(string) **out = **in } + 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 + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DorisMonitorSpec. @@ -1099,6 +1113,13 @@ func (in *GrafanaSpec) DeepCopyInto(out *GrafanaSpec) { (*in).DeepCopyInto(*out) } in.ResourceRequirements.DeepCopyInto(&out.ResourceRequirements) + 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 + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrafanaSpec. @@ -1178,6 +1199,13 @@ func (in *LokiSpec) DeepCopyInto(out *LokiSpec) { **out = **in } in.ResourceRequirements.DeepCopyInto(&out.ResourceRequirements) + 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 + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LokiSpec. @@ -1260,6 +1288,13 @@ func (in *PrometheusSpec) DeepCopyInto(out *PrometheusSpec) { (*in).DeepCopyInto(*out) } in.ResourceRequirements.DeepCopyInto(&out.ResourceRequirements) + 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 + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrometheusSpec. diff --git a/config/crd/bases/al-assad.github.io_dorisinitializers.yaml b/config/crd/bases/al-assad.github.io_dorisinitializers.yaml index 05abc0f..8c58a0d 100644 --- a/config/crd/bases/al-assad.github.io_dorisinitializers.yaml +++ b/config/crd/bases/al-assad.github.io_dorisinitializers.yaml @@ -69,6 +69,10 @@ spec: maxRetry: format: int32 type: integer + nodeSelector: + additionalProperties: + type: string + type: object requests: additionalProperties: anyOf: diff --git a/config/crd/bases/al-assad.github.io_dorismonitors.yaml b/config/crd/bases/al-assad.github.io_dorismonitors.yaml index 4ea0c13..fc73964 100644 --- a/config/crd/bases/al-assad.github.io_dorismonitors.yaml +++ b/config/crd/bases/al-assad.github.io_dorismonitors.yaml @@ -60,6 +60,10 @@ spec: pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true type: object + nodeSelector: + additionalProperties: + type: string + type: object requests: additionalProperties: anyOf: @@ -117,6 +121,10 @@ spec: pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true type: object + nodeSelector: + additionalProperties: + type: string + type: object requests: additionalProperties: anyOf: @@ -132,6 +140,10 @@ spec: required: - image type: object + nodeSelector: + additionalProperties: + type: string + type: object prometheus: properties: claims: @@ -156,6 +168,10 @@ spec: pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true type: object + nodeSelector: + additionalProperties: + type: string + type: object requests: additionalProperties: anyOf: diff --git a/examples/advanced/doris-cluster.yaml b/examples/advanced/doris-cluster.yaml index bc2f258..16756fa 100644 --- a/examples/advanced/doris-cluster.yaml +++ b/examples/advanced/doris-cluster.yaml @@ -24,6 +24,11 @@ spec: ## Specifies the service account for FE/BE/CN/Broker components. # serviceAccount: "" + ## NodeSelector of pods。 + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + # nodeSelector: + # node-role.kubernetes.io/doris: true + ## Affinity for pod scheduling ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity # affinity: @@ -178,6 +183,8 @@ spec: # tolerations: {} # priorityClassName: "" # statefulSetUpdateStrategy: RollingUpdate + # nodeSelector: + # app.kubernetes.io/component: fe ############################### @@ -267,6 +274,8 @@ spec: # tolerations: {} # priorityClassName: "" # statefulSetUpdateStrategy: RollingUpdate + # nodeSelector: + # app.kubernetes.io/component: be ##################################### @@ -352,6 +361,8 @@ spec: # tolerations: {} # priorityClassName: "" # statefulSetUpdateStrategy: RollingUpdate + # nodeSelector: + # app.kubernetes.io/component: cn ####################### @@ -432,4 +443,6 @@ spec: # affinity: {} # tolerations: {} # priorityClassName: "" - # statefulSetUpdateStrategy: RollingUpdate \ No newline at end of file + # statefulSetUpdateStrategy: RollingUpdate + # nodeSelector: + # app.kubernetes.io/component: broker \ No newline at end of file diff --git a/examples/advanced/doris-monitor.yaml b/examples/advanced/doris-monitor.yaml index ae8e9bc..f104485 100644 --- a/examples/advanced/doris-monitor.yaml +++ b/examples/advanced/doris-monitor.yaml @@ -24,6 +24,11 @@ spec: ## Whether to disable Loki for log collection # disableLoki: false + ## NodeSelector of pods。 + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + # nodeSelector: + # node-role.kubernetes.io/doris-monitor: true + ########################### # Prometheus Configuration # ########################### @@ -53,6 +58,8 @@ spec: # type: NodePort # httpPort: 0 + ## NodeSelector of pods。 + # nodeSelector: {} ######################## # Grafana Configuration # @@ -85,6 +92,9 @@ spec: # type: NodePort # httpPort: 0 + ## NodeSelector of pods。 + # nodeSelector: {} + ##################### # Loki Configuration # ##################### @@ -111,6 +121,9 @@ spec: ## The storageClassName of the persistent volume for grafana data storage. # storageClassName: "" + ## NodeSelector of pods。 + # nodeSelector: {} + ######################### # Promtail Configuration # ######################### diff --git a/internal/transformer/grafana_resources.go b/internal/transformer/grafana_resources.go index c186116..0a42d59 100644 --- a/internal/transformer/grafana_resources.go +++ b/internal/transformer/grafana_resources.go @@ -252,6 +252,7 @@ func MakeGrafanaDeployment(cr *dapi.DorisMonitor, scheme *runtime.Scheme) *appv1 Spec: corev1.PodSpec{ ServiceAccountName: cr.Spec.ServiceAccount, ImagePullSecrets: cr.Spec.ImagePullSecrets, + NodeSelector: util.MapFallback(cr.Spec.Grafana.NodeSelector, cr.Spec.NodeSelector), Volumes: []corev1.Volume{ { Name: "grafana-datasource", diff --git a/internal/transformer/initializer_resources.go b/internal/transformer/initializer_resources.go index e29ca31..4055415 100644 --- a/internal/transformer/initializer_resources.go +++ b/internal/transformer/initializer_resources.go @@ -234,6 +234,7 @@ func MakeInitializerJob(cr *dapi.DorisInitializer, feSvcQueryPort int32, scheme Containers: []corev1.Container{mainContainer}, ImagePullSecrets: cr.Spec.ImagePullSecrets, Tolerations: cr.Spec.Tolerations, + NodeSelector: cr.Spec.NodeSelector, }, } diff --git a/internal/transformer/loki_resources.go b/internal/transformer/loki_resources.go index e639ccf..02e46d7 100644 --- a/internal/transformer/loki_resources.go +++ b/internal/transformer/loki_resources.go @@ -194,6 +194,7 @@ func MakeLokiDeployment(cr *dapi.DorisMonitor, scheme *runtime.Scheme) *appv1.De Spec: corev1.PodSpec{ ServiceAccountName: cr.Spec.ServiceAccount, ImagePullSecrets: cr.Spec.ImagePullSecrets, + NodeSelector: util.MapFallback(cr.Spec.Loki.NodeSelector, cr.Spec.NodeSelector), Volumes: []corev1.Volume{ { Name: "config", diff --git a/internal/transformer/prometheus_resources.go b/internal/transformer/prometheus_resources.go index 5ba1447..3921da8 100644 --- a/internal/transformer/prometheus_resources.go +++ b/internal/transformer/prometheus_resources.go @@ -208,6 +208,7 @@ func MakePrometheusDeployment(cr *dapi.DorisMonitor, scheme *runtime.Scheme) *ap Spec: corev1.PodSpec{ ServiceAccountName: MonitorNamespacedAccountName, ImagePullSecrets: cr.Spec.ImagePullSecrets, + NodeSelector: util.MapFallback(cr.Spec.Prometheus.NodeSelector, cr.Spec.NodeSelector), Volumes: []corev1.Volume{ { Name: "prometheus-config",