Skip to content

Commit

Permalink
Merge pull request #31 from Al-assad/dev
Browse files Browse the repository at this point in the history
Support customize annotations for Doris components.
  • Loading branch information
Al-assad authored Nov 30, 2023
2 parents 0153459 + 69f6b48 commit a4fc9e4
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 9 deletions.
8 changes: 8 additions & 0 deletions api/v1beta1/doriscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ type DorisClusterSpec struct {
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// Annotations of the Doris cluster.
// +optional
Annotations map[string]string `json:"annotations,omitempty"`

// Tolerations are applied to Doris cluster pods, allowing pods to be scheduled onto nodes with matching taints.
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Expand Down Expand Up @@ -240,6 +244,10 @@ type DorisComponentSpec struct {
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// Annotations of the component.
// +optional
Annotations map[string]string `json:"annotations,omitempty"`

// Affinity for pod scheduling of Doris cluster.
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Expand Down
14 changes: 14 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.

20 changes: 20 additions & 0 deletions config/crd/bases/al-assad.github.io_dorisclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ spec:
type: array
type: object
type: object
annotations:
additionalProperties:
type: string
type: object
be:
properties:
additionalContainers:
Expand Down Expand Up @@ -2173,6 +2177,10 @@ spec:
type: array
type: object
type: object
annotations:
additionalProperties:
type: string
type: object
baseImage:
type: string
claims:
Expand Down Expand Up @@ -4059,6 +4067,10 @@ spec:
type: array
type: object
type: object
annotations:
additionalProperties:
type: string
type: object
baseImage:
type: string
claims:
Expand Down Expand Up @@ -5922,6 +5934,10 @@ spec:
type: array
type: object
type: object
annotations:
additionalProperties:
type: string
type: object
baseImage:
type: string
claims:
Expand Down Expand Up @@ -7783,6 +7799,10 @@ spec:
type: array
type: object
type: object
annotations:
additionalProperties:
type: string
type: object
baseImage:
type: string
claims:
Expand Down
7 changes: 6 additions & 1 deletion internal/transformer/be_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,16 @@ func MakeBeStatefulSet(cr *dapi.DorisCluster, scheme *runtime.Scheme) *appv1.Sta
hostAlias = cr.Spec.BE.HostAliases
}

// pod templateL annotations
podAnnotations := util.MergeMaps(cr.Annotations, cr.Spec.BE.Annotations)
metricsAnnotations := MakePrometheusAnnotations("/metrics", GetBeWebserverPort(cr))
podAnnotations = util.MergeMaps(metricsAnnotations, podAnnotations)

// pod template
podTemplate := corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: beLabels,
Annotations: MakePrometheusAnnotations("/metrics", GetBeWebserverPort(cr)),
Annotations: podAnnotations,
},
Spec: corev1.PodSpec{
Volumes: volumes,
Expand Down
2 changes: 1 addition & 1 deletion internal/transformer/broker_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func MakeBrokerStatefulSet(cr *dapi.DorisCluster, scheme *runtime.Scheme) *appv1
podTemplate := corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: brokerLabels,
Annotations: make(map[string]string),
Annotations: util.MergeMaps(cr.Annotations, cr.Spec.Broker.Annotations),
},
Spec: corev1.PodSpec{
Volumes: volumes,
Expand Down
7 changes: 6 additions & 1 deletion internal/transformer/cn_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,16 @@ func MakeCnStatefulSet(cr *dapi.DorisCluster, scheme *runtime.Scheme) *appv1.Sta
hostAlias = cr.Spec.CN.HostAliases
}

// pod templateL annotations
podAnnotations := util.MergeMaps(cr.Annotations, cr.Spec.CN.Annotations)
metricsAnnotations := MakePrometheusAnnotations("/metrics", GetCnWebserverPort(cr))
podAnnotations = util.MergeMaps(metricsAnnotations, podAnnotations)

// pod template
podTemplate := corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: cnLabels,
Annotations: MakePrometheusAnnotations("/metrics", GetBeWebserverPort(cr)),
Annotations: podAnnotations,
},
Spec: corev1.PodSpec{
Volumes: volumes,
Expand Down
17 changes: 11 additions & 6 deletions internal/transformer/fe_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,20 @@ func MakeFeStatefulSet(cr *dapi.DorisCluster, scheme *runtime.Scheme) *appv1.Sta
hostAlias = cr.Spec.FE.HostAliases
}

// pod template: annotation
podAnnotations := util.MergeMaps(cr.Annotations, cr.Spec.FE.Annotations)
metricsAnnotations := map[string]string{
PrometheusPathAnnoKey: "/metrics",
PrometheusPortAnnoKey: strconv.Itoa(int(GetFeHttpPort(cr))),
PrometheusScrapeAnnoKey: "true",
}
podAnnotations = util.MergeMaps(metricsAnnotations, podAnnotations)

// pod template
podTemplate := corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: feLabels,
Annotations: map[string]string{
PrometheusPathAnnoKey: "/metrics",
PrometheusPortAnnoKey: strconv.Itoa(int(GetFeHttpPort(cr))),
PrometheusScrapeAnnoKey: "true",
},
Labels: feLabels,
Annotations: podAnnotations,
},
Spec: corev1.PodSpec{
Volumes: volumes,
Expand Down

0 comments on commit a4fc9e4

Please sign in to comment.