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 <wuyangmuc@gmail.com>
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
*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 @@
*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 *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 @@
*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 @@
},
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 @@
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 @@
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 @@
"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 @@
},
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 @@
},
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 @@
import (
"context"
- "github.com/google/uuid"
"os/exec"
"reflect"
"sort"
@@ -28,6 +27,8 @@
"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 @@
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
- Labels: ls,
+ Labels: ls,
+ Annotations: nameService.Spec.PodAnnotations,
},
Spec: corev1.PodSpec{
ServiceAccountName: nameService.Spec.ServiceAccountName,