diff --git a/api/v1beta1/doriscluster_types.go b/api/v1beta1/doriscluster_types.go index 8c90868..b770343 100644 --- a/api/v1beta1/doriscluster_types.go +++ b/api/v1beta1/doriscluster_types.go @@ -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"` @@ -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"` diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 7f78412..03d513d 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -528,6 +528,13 @@ func (in *DorisClusterSpec) DeepCopyInto(out *DorisClusterSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *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([]v1.Toleration, len(*in)) @@ -618,6 +625,13 @@ func (in *DorisComponentSpec) DeepCopyInto(out *DorisComponentSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.Affinity != nil { in, out := &in.Affinity, &out.Affinity *out = new(v1.Affinity) diff --git a/config/crd/bases/al-assad.github.io_dorisclusters.yaml b/config/crd/bases/al-assad.github.io_dorisclusters.yaml index 8c57427..f385535 100644 --- a/config/crd/bases/al-assad.github.io_dorisclusters.yaml +++ b/config/crd/bases/al-assad.github.io_dorisclusters.yaml @@ -393,6 +393,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object be: properties: additionalContainers: @@ -2173,6 +2177,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object baseImage: type: string claims: @@ -4059,6 +4067,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object baseImage: type: string claims: @@ -5922,6 +5934,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object baseImage: type: string claims: @@ -7783,6 +7799,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object baseImage: type: string claims: diff --git a/internal/transformer/be_resources.go b/internal/transformer/be_resources.go index 19b9d75..cba30dc 100644 --- a/internal/transformer/be_resources.go +++ b/internal/transformer/be_resources.go @@ -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, diff --git a/internal/transformer/broker_resources.go b/internal/transformer/broker_resources.go index 16c1a68..8740414 100644 --- a/internal/transformer/broker_resources.go +++ b/internal/transformer/broker_resources.go @@ -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, diff --git a/internal/transformer/cn_resources.go b/internal/transformer/cn_resources.go index 4dda206..bc7df09 100644 --- a/internal/transformer/cn_resources.go +++ b/internal/transformer/cn_resources.go @@ -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, diff --git a/internal/transformer/fe_resources.go b/internal/transformer/fe_resources.go index c3026d2..4e29f91 100644 --- a/internal/transformer/fe_resources.go +++ b/internal/transformer/fe_resources.go @@ -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,