This is an automated email from the ASF dual-hosted git repository.

caigy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-operator.git


The following commit(s) were added to refs/heads/master by this push:
     new 03741c8  Add podAnnotations field to CRDs and types for Broker, 
Controller, and NameService (#236)
03741c8 is described below

commit 03741c8521a8d5063a1d5c1d1d704f1072e9d767
Author: yangw <wuyang...@gmail.com>
AuthorDate: Tue Jan 14 13:56:29 2025 +0800

    Add podAnnotations field to CRDs and types for Broker, Controller, and 
NameService (#236)
    
    This commit introduces a new field, podAnnotations, to the CRDs and 
corresponding types for Broker, Controller, and NameService. This allows users 
to specify annotations for the pods created by these resources, enhancing 
customization and configuration options for deployments.
    
    Signed-off-by: yangw <wuyang...@gmail.com>
---
 .../crds/rocketmq.apache.org_brokers.yaml          |  5 ++++
 .../crds/rocketmq.apache.org_controllers.yaml      |  5 ++++
 .../crds/rocketmq.apache.org_nameservices.yaml     |  5 ++++
 deploy/crds/rocketmq.apache.org_brokers.yaml       |  5 ++++
 deploy/crds/rocketmq.apache.org_controllers.yaml   |  5 ++++
 deploy/crds/rocketmq.apache.org_nameservices.yaml  |  5 ++++
 pkg/apis/rocketmq/v1alpha1/broker_types.go         |  2 ++
 pkg/apis/rocketmq/v1alpha1/controller_types.go     |  2 ++
 pkg/apis/rocketmq/v1alpha1/nameservice_types.go    |  2 ++
 .../rocketmq/v1alpha1/zz_generated.deepcopy.go     | 28 ++++++++++++++++++++++
 pkg/controller/broker/broker_controller.go         |  3 ++-
 pkg/controller/console/console_controller.go       |  8 ++++---
 pkg/controller/controller/dledger_controller.go    |  3 ++-
 .../nameservice/nameservice_controller.go          |  6 +++--
 14 files changed, 77 insertions(+), 7 deletions(-)

diff --git a/charts/rocketmq-operator/crds/rocketmq.apache.org_brokers.yaml 
b/charts/rocketmq-operator/crds/rocketmq.apache.org_brokers.yaml
index ffc0ad1..3d71b64 100644
--- a/charts/rocketmq-operator/crds/rocketmq.apache.org_brokers.yaml
+++ b/charts/rocketmq-operator/crds/rocketmq.apache.org_brokers.yaml
@@ -1171,6 +1171,11 @@ spec:
                 description: NodeSelector is a selector which must be true for 
the
                   pod to fit on a node
                 type: object
+              podAnnotations:
+                additionalProperties:
+                  type: string
+                description: Pod Annotations
+                type: object
               priorityClassName:
                 description: PriorityClassName indicates the pod's priority
                 type: string
diff --git a/charts/rocketmq-operator/crds/rocketmq.apache.org_controllers.yaml 
b/charts/rocketmq-operator/crds/rocketmq.apache.org_controllers.yaml
index 4f98506..7993880 100644
--- a/charts/rocketmq-operator/crds/rocketmq.apache.org_controllers.yaml
+++ b/charts/rocketmq-operator/crds/rocketmq.apache.org_controllers.yaml
@@ -1149,6 +1149,11 @@ spec:
                 description: NodeSelector is a selector which must be true for 
the
                   pod to fit on a node
                 type: object
+              podAnnotations:
+                additionalProperties:
+                  type: string
+                description: Pod Annotations
+                type: object
               priorityClassName:
                 description: PriorityClassName indicates the pod's priority
                 type: string
diff --git 
a/charts/rocketmq-operator/crds/rocketmq.apache.org_nameservices.yaml 
b/charts/rocketmq-operator/crds/rocketmq.apache.org_nameservices.yaml
index 49317b0..3f6676d 100644
--- a/charts/rocketmq-operator/crds/rocketmq.apache.org_nameservices.yaml
+++ b/charts/rocketmq-operator/crds/rocketmq.apache.org_nameservices.yaml
@@ -1158,6 +1158,11 @@ spec:
                 description: NodeSelector is a selector which must be true for 
the
                   pod to fit on a node
                 type: object
+              podAnnotations:
+                additionalProperties:
+                  type: string
+                description: Pod Annotations
+                type: object
               priorityClassName:
                 description: PriorityClassName indicates the pod's priority
                 type: string
diff --git a/deploy/crds/rocketmq.apache.org_brokers.yaml 
b/deploy/crds/rocketmq.apache.org_brokers.yaml
index ffc0ad1..3d71b64 100644
--- a/deploy/crds/rocketmq.apache.org_brokers.yaml
+++ b/deploy/crds/rocketmq.apache.org_brokers.yaml
@@ -1171,6 +1171,11 @@ spec:
                 description: NodeSelector is a selector which must be true for 
the
                   pod to fit on a node
                 type: object
+              podAnnotations:
+                additionalProperties:
+                  type: string
+                description: Pod Annotations
+                type: object
               priorityClassName:
                 description: PriorityClassName indicates the pod's priority
                 type: string
diff --git a/deploy/crds/rocketmq.apache.org_controllers.yaml 
b/deploy/crds/rocketmq.apache.org_controllers.yaml
index 4f98506..7993880 100644
--- a/deploy/crds/rocketmq.apache.org_controllers.yaml
+++ b/deploy/crds/rocketmq.apache.org_controllers.yaml
@@ -1149,6 +1149,11 @@ spec:
                 description: NodeSelector is a selector which must be true for 
the
                   pod to fit on a node
                 type: object
+              podAnnotations:
+                additionalProperties:
+                  type: string
+                description: Pod Annotations
+                type: object
               priorityClassName:
                 description: PriorityClassName indicates the pod's priority
                 type: string
diff --git a/deploy/crds/rocketmq.apache.org_nameservices.yaml 
b/deploy/crds/rocketmq.apache.org_nameservices.yaml
index 49317b0..3f6676d 100644
--- a/deploy/crds/rocketmq.apache.org_nameservices.yaml
+++ b/deploy/crds/rocketmq.apache.org_nameservices.yaml
@@ -1158,6 +1158,11 @@ spec:
                 description: NodeSelector is a selector which must be true for 
the
                   pod to fit on a node
                 type: object
+              podAnnotations:
+                additionalProperties:
+                  type: string
+                description: Pod Annotations
+                type: object
               priorityClassName:
                 description: PriorityClassName indicates the pod's priority
                 type: string
diff --git a/pkg/apis/rocketmq/v1alpha1/broker_types.go 
b/pkg/apis/rocketmq/v1alpha1/broker_types.go
index 1647f9a..c9712cf 100644
--- a/pkg/apis/rocketmq/v1alpha1/broker_types.go
+++ b/pkg/apis/rocketmq/v1alpha1/broker_types.go
@@ -66,6 +66,8 @@ type BrokerSpec struct {
        ScalePodName string `json:"scalePodName"`
        // Pod Security Context
        PodSecurityContext *corev1.PodSecurityContext 
`json:"securityContext,omitempty"`
+       // Pod Annotations
+       PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
        // Container Security Context
        ContainerSecurityContext *corev1.SecurityContext 
`json:"containerSecurityContext,omitempty"`
        // The secrets used to pull image from private registry
diff --git a/pkg/apis/rocketmq/v1alpha1/controller_types.go 
b/pkg/apis/rocketmq/v1alpha1/controller_types.go
index 5e8152c..efe3ce7 100644
--- a/pkg/apis/rocketmq/v1alpha1/controller_types.go
+++ b/pkg/apis/rocketmq/v1alpha1/controller_types.go
@@ -54,6 +54,8 @@ type ControllerSpec struct {
 
        // Pod Security Context
        PodSecurityContext *corev1.PodSecurityContext 
`json:"securityContext,omitempty"`
+       // Pod Annotations
+       PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
        // Container Security Context
        ContainerSecurityContext *corev1.SecurityContext 
`json:"containerSecurityContext,omitempty"`
        // The secrets used to pull image from private registry
diff --git a/pkg/apis/rocketmq/v1alpha1/nameservice_types.go 
b/pkg/apis/rocketmq/v1alpha1/nameservice_types.go
index 007b6e0..d227730 100644
--- a/pkg/apis/rocketmq/v1alpha1/nameservice_types.go
+++ b/pkg/apis/rocketmq/v1alpha1/nameservice_types.go
@@ -53,6 +53,8 @@ type NameServiceSpec struct {
        VolumeClaimTemplates []corev1.PersistentVolumeClaim 
`json:"volumeClaimTemplates"`
        // Pod Security Context
        PodSecurityContext *corev1.PodSecurityContext 
`json:"securityContext,omitempty"`
+       // Pod Annotations
+       PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
        // Container Security Context
        ContainerSecurityContext *corev1.SecurityContext 
`json:"containerSecurityContext,omitempty"`
        // The secrets used to pull image from private registry
diff --git a/pkg/apis/rocketmq/v1alpha1/zz_generated.deepcopy.go 
b/pkg/apis/rocketmq/v1alpha1/zz_generated.deepcopy.go
index 22a1902..850444f 100644
--- a/pkg/apis/rocketmq/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/rocketmq/v1alpha1/zz_generated.deepcopy.go
@@ -114,6 +114,13 @@ func (in *BrokerSpec) DeepCopyInto(out *BrokerSpec) {
                *out = new(v1.PodSecurityContext)
                (*in).DeepCopyInto(*out)
        }
+       if in.PodAnnotations != nil {
+               in, out := &in.PodAnnotations, &out.PodAnnotations
+               *out = make(map[string]string, len(*in))
+               for key, val := range *in {
+                       (*out)[key] = val
+               }
+       }
        if in.ContainerSecurityContext != nil {
                in, out := &in.ContainerSecurityContext, 
&out.ContainerSecurityContext
                *out = new(v1.SecurityContext)
@@ -347,6 +354,13 @@ func (in *ControllerSpec) DeepCopyInto(out 
*ControllerSpec) {
                *out = new(v1.PodSecurityContext)
                (*in).DeepCopyInto(*out)
        }
+       if in.PodAnnotations != nil {
+               in, out := &in.PodAnnotations, &out.PodAnnotations
+               *out = make(map[string]string, len(*in))
+               for key, val := range *in {
+                       (*out)[key] = val
+               }
+       }
        if in.ContainerSecurityContext != nil {
                in, out := &in.ContainerSecurityContext, 
&out.ContainerSecurityContext
                *out = new(v1.SecurityContext)
@@ -471,6 +485,13 @@ func (in *NameServiceList) DeepCopyObject() runtime.Object 
{
 func (in *NameServiceSpec) DeepCopyInto(out *NameServiceSpec) {
        *out = *in
        in.Resources.DeepCopyInto(&out.Resources)
+       if in.Env != nil {
+               in, out := &in.Env, &out.Env
+               *out = make([]v1.EnvVar, len(*in))
+               for i := range *in {
+                       (*in)[i].DeepCopyInto(&(*out)[i])
+               }
+       }
        if in.VolumeClaimTemplates != nil {
                in, out := &in.VolumeClaimTemplates, &out.VolumeClaimTemplates
                *out = make([]v1.PersistentVolumeClaim, len(*in))
@@ -483,6 +504,13 @@ func (in *NameServiceSpec) DeepCopyInto(out 
*NameServiceSpec) {
                *out = new(v1.PodSecurityContext)
                (*in).DeepCopyInto(*out)
        }
+       if in.PodAnnotations != nil {
+               in, out := &in.PodAnnotations, &out.PodAnnotations
+               *out = make(map[string]string, len(*in))
+               for key, val := range *in {
+                       (*out)[key] = val
+               }
+       }
        if in.ContainerSecurityContext != nil {
                in, out := &in.ContainerSecurityContext, 
&out.ContainerSecurityContext
                *out = new(v1.SecurityContext)
diff --git a/pkg/controller/broker/broker_controller.go 
b/pkg/controller/broker/broker_controller.go
index f6ea664..9cf5141 100644
--- a/pkg/controller/broker/broker_controller.go
+++ b/pkg/controller/broker/broker_controller.go
@@ -449,7 +449,8 @@ func (r *ReconcileBroker) getBrokerStatefulSet(broker 
*rocketmqv1alpha1.Broker,
                        },
                        Template: corev1.PodTemplateSpec{
                                ObjectMeta: metav1.ObjectMeta{
-                                       Labels: ls,
+                                       Labels:      ls,
+                                       Annotations: broker.Spec.PodAnnotations,
                                },
                                Spec: corev1.PodSpec{
                                        ServiceAccountName: 
broker.Spec.ServiceAccountName,
diff --git a/pkg/controller/console/console_controller.go 
b/pkg/controller/console/console_controller.go
index 9eb1e4c..011ac4d 100644
--- a/pkg/controller/console/console_controller.go
+++ b/pkg/controller/console/console_controller.go
@@ -20,6 +20,9 @@ package console
 import (
        "context"
        "fmt"
+       "reflect"
+       "time"
+
        rocketmqv1alpha1 
"github.com/apache/rocketmq-operator/pkg/apis/rocketmq/v1alpha1"
        cons "github.com/apache/rocketmq-operator/pkg/constants"
        "github.com/apache/rocketmq-operator/pkg/share"
@@ -29,7 +32,6 @@ import (
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
        "k8s.io/apimachinery/pkg/runtime"
        "k8s.io/apimachinery/pkg/types"
-       "reflect"
        "sigs.k8s.io/controller-runtime/pkg/client"
        "sigs.k8s.io/controller-runtime/pkg/controller"
        "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -38,7 +40,6 @@ import (
        "sigs.k8s.io/controller-runtime/pkg/manager"
        "sigs.k8s.io/controller-runtime/pkg/reconcile"
        "sigs.k8s.io/controller-runtime/pkg/source"
-       "time"
 )
 
 var log = logf.Log.WithName("controller_console")
@@ -201,7 +202,8 @@ func newDeploymentForCR(cr *rocketmqv1alpha1.Console) 
*appsv1.Deployment {
                        },
                        Template: corev1.PodTemplateSpec{
                                ObjectMeta: metav1.ObjectMeta{
-                                       Labels: 
cr.Spec.ConsoleDeployment.Spec.Template.ObjectMeta.Labels,
+                                       Labels:      
cr.Spec.ConsoleDeployment.Spec.Template.ObjectMeta.Labels,
+                                       Annotations: 
cr.Spec.ConsoleDeployment.Spec.Template.ObjectMeta.Annotations,
                                },
                                Spec: corev1.PodSpec{
                                        ServiceAccountName: 
cr.Spec.ConsoleDeployment.Spec.Template.Spec.ServiceAccountName,
diff --git a/pkg/controller/controller/dledger_controller.go 
b/pkg/controller/controller/dledger_controller.go
index 1056f24..f060af4 100644
--- a/pkg/controller/controller/dledger_controller.go
+++ b/pkg/controller/controller/dledger_controller.go
@@ -257,7 +257,8 @@ func (r *ReconcileController) 
getControllerStatefulSet(controller *rocketmqv1alp
                        },
                        Template: corev1.PodTemplateSpec{
                                ObjectMeta: metav1.ObjectMeta{
-                                       Labels: ls,
+                                       Labels:      ls,
+                                       Annotations: 
controller.Spec.PodAnnotations,
                                },
                                Spec: corev1.PodSpec{
 
diff --git a/pkg/controller/nameservice/nameservice_controller.go 
b/pkg/controller/nameservice/nameservice_controller.go
index 88fe0fa..ffd3c81 100644
--- a/pkg/controller/nameservice/nameservice_controller.go
+++ b/pkg/controller/nameservice/nameservice_controller.go
@@ -20,7 +20,6 @@ package nameservice
 
 import (
        "context"
-       "github.com/google/uuid"
        "os/exec"
        "reflect"
        "sort"
@@ -28,6 +27,8 @@ import (
        "strings"
        "time"
 
+       "github.com/google/uuid"
+
        rocketmqv1alpha1 
"github.com/apache/rocketmq-operator/pkg/apis/rocketmq/v1alpha1"
        cons "github.com/apache/rocketmq-operator/pkg/constants"
        "github.com/apache/rocketmq-operator/pkg/share"
@@ -357,7 +358,8 @@ func (r *ReconcileNameService) 
statefulSetForNameService(nameService *rocketmqv1
                        },
                        Template: corev1.PodTemplateSpec{
                                ObjectMeta: metav1.ObjectMeta{
-                                       Labels: ls,
+                                       Labels:      ls,
+                                       Annotations: 
nameService.Spec.PodAnnotations,
                                },
                                Spec: corev1.PodSpec{
                                        ServiceAccountName: 
nameService.Spec.ServiceAccountName,

Reply via email to