Skip to content

Commit

Permalink
Add podAnnotations field to CRDs and types for Broker, Controller, an…
Browse files Browse the repository at this point in the history
…d NameService

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 <[email protected]>
  • Loading branch information
drivebyer committed Dec 12, 2024
1 parent 9752d8c commit 3e53c49
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions deploy/crds/rocketmq.apache.org_brokers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions deploy/crds/rocketmq.apache.org_controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions deploy/crds/rocketmq.apache.org_nameservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/rocketmq/v1alpha1/broker_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/rocketmq/v1alpha1/controller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/rocketmq/v1alpha1/nameservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions pkg/apis/rocketmq/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 2 additions & 1 deletion pkg/controller/broker/broker_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions pkg/controller/console/console_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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")
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/controller/dledger_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{

Expand Down
6 changes: 4 additions & 2 deletions pkg/controller/nameservice/nameservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ package nameservice

import (
"context"
"github.com/google/uuid"
"os/exec"
"reflect"
"sort"
"strconv"
"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"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3e53c49

Please sign in to comment.