Skip to content

Commit

Permalink
Merge pull request #17 from Al-assad/dev
Browse files Browse the repository at this point in the history
Supports NodeSelector properties for DorisInitializer & DorisMonitor CRD
  • Loading branch information
Al-assad committed Nov 1, 2023
2 parents f42ecee + 3e324ff commit 8e17945
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 2 deletions.
4 changes: 4 additions & 0 deletions api/v1beta1/dorisinitializer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion api/v1beta1/dorismonitor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"`
}
Expand Down
35 changes: 35 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions config/crd/bases/al-assad.github.io_dorisinitializers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ spec:
maxRetry:
format: int32
type: integer
nodeSelector:
additionalProperties:
type: string
type: object
requests:
additionalProperties:
anyOf:
Expand Down
16 changes: 16 additions & 0 deletions config/crd/bases/al-assad.github.io_dorismonitors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -132,6 +140,10 @@ spec:
required:
- image
type: object
nodeSelector:
additionalProperties:
type: string
type: object
prometheus:
properties:
claims:
Expand All @@ -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:
Expand Down
15 changes: 14 additions & 1 deletion examples/advanced/doris-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -178,6 +183,8 @@ spec:
# tolerations: {}
# priorityClassName: ""
# statefulSetUpdateStrategy: RollingUpdate
# nodeSelector:
# app.kubernetes.io/component: fe


###############################
Expand Down Expand Up @@ -267,6 +274,8 @@ spec:
# tolerations: {}
# priorityClassName: ""
# statefulSetUpdateStrategy: RollingUpdate
# nodeSelector:
# app.kubernetes.io/component: be


#####################################
Expand Down Expand Up @@ -352,6 +361,8 @@ spec:
# tolerations: {}
# priorityClassName: ""
# statefulSetUpdateStrategy: RollingUpdate
# nodeSelector:
# app.kubernetes.io/component: cn


#######################
Expand Down Expand Up @@ -432,4 +443,6 @@ spec:
# affinity: {}
# tolerations: {}
# priorityClassName: ""
# statefulSetUpdateStrategy: RollingUpdate
# statefulSetUpdateStrategy: RollingUpdate
# nodeSelector:
# app.kubernetes.io/component: broker
13 changes: 13 additions & 0 deletions examples/advanced/doris-monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
###########################
Expand Down Expand Up @@ -53,6 +58,8 @@ spec:
# type: NodePort
# httpPort: 0

## NodeSelector of pods。
# nodeSelector: {}

########################
# Grafana Configuration #
Expand Down Expand Up @@ -85,6 +92,9 @@ spec:
# type: NodePort
# httpPort: 0

## NodeSelector of pods。
# nodeSelector: {}

#####################
# Loki Configuration #
#####################
Expand All @@ -111,6 +121,9 @@ spec:
## The storageClassName of the persistent volume for grafana data storage.
# storageClassName: ""

## NodeSelector of pods。
# nodeSelector: {}

#########################
# Promtail Configuration #
#########################
Expand Down
1 change: 1 addition & 0 deletions internal/transformer/grafana_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions internal/transformer/initializer_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}

Expand Down
1 change: 1 addition & 0 deletions internal/transformer/loki_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions internal/transformer/prometheus_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 8e17945

Please sign in to comment.