Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions example/rocketmq_v1alpha1_broker_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ data:
flushDiskType=ASYNC_FLUSH
# set brokerRole to ASYNC_MASTER or SYNC_MASTER. DO NOT set to SLAVE because the replica instance will automatically be set!!!
brokerRole=ASYNC_MASTER
# set aclEnable to true to enable ACL, and set plain_acl.yml to configure ACL
aclEnable=false

plain_acl.yml: |
globalWhiteRemoteAddresses:
accounts:
- accessKey: RocketMQ
secretKey: 12345678
whiteRemoteAddress:
admin: false
defaultTopicPerm: DENY
defaultGroupPerm: SUB
topicPerms:
- TopicTest=PUB
groupPerms:
# the group should convert to retry topic
- oms_consumer_group=DENY


---
apiVersion: rocketmq.apache.org/v1alpha1
Expand Down Expand Up @@ -75,6 +93,13 @@ spec:
items:
- key: broker-common.conf
path: broker-common.conf
# uncomment the following to enable ACL
# - name: plain-acl
# configMap:
# name: broker-config
# items:
# - key: plain_acl.yml
# path: plain_acl.yml
# volumeClaimTemplates defines the storageClass
volumeClaimTemplates:
- metadata:
Expand Down
4 changes: 4 additions & 0 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const (
// BrokerConfigName is the name of mounted configuration file
BrokerConfigName = "broker-common.conf"

BrokerPlainAclConfigName = "plain_acl.yml"

BrokerPlainAclConfigPath = DataPath + "/rocketmq/broker/conf"

// UpdateBrokerConfig is update broker config command
UpdateBrokerConfig = "updateBrokerConfig"

Expand Down
38 changes: 25 additions & 13 deletions pkg/controller/broker/broker_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,19 +484,7 @@ func (r *ReconcileBroker) getBrokerStatefulSet(broker *rocketmqv1alpha1.Broker,
ContainerPort: cons.BrokerHighAvailabilityContainerPort,
Name: cons.BrokerHighAvailabilityContainerPortName,
}},
VolumeMounts: []corev1.VolumeMount{{
MountPath: cons.LogMountPath,
Name: broker.Spec.VolumeClaimTemplates[0].Name,
SubPath: cons.LogSubPathName + getPathSuffix(broker, brokerGroupIndex, replicaIndex),
}, {
MountPath: cons.StoreMountPath,
Name: broker.Spec.VolumeClaimTemplates[0].Name,
SubPath: cons.StoreSubPathName + getPathSuffix(broker, brokerGroupIndex, replicaIndex),
}, {
MountPath: cons.BrokerConfigPath + "/" + cons.BrokerConfigName,
Name: broker.Spec.Volumes[0].Name,
SubPath: cons.BrokerConfigName,
}},
VolumeMounts: getVolumeMounts(broker, brokerGroupIndex, replicaIndex),
}},
Volumes: getVolumes(broker),
SecurityContext: getPodSecurityContext(broker),
Expand All @@ -512,6 +500,30 @@ func (r *ReconcileBroker) getBrokerStatefulSet(broker *rocketmqv1alpha1.Broker,

}

func getVolumeMounts(broker *rocketmqv1alpha1.Broker, brokerGroupIndex int, replicaIndex int) []corev1.VolumeMount {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a bit complicated. I'd prefer separating ACL related configs from other broker configs, and let user provide the name of configmap/secret of ACL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your point, but it seems that there isn’t much difference with this method. If users specify ACL configurations in a separate YAML file, they would still need to maintain common configurations and ACL configurations in two separate files, even though both are for the broker.

mounts := []corev1.VolumeMount{{
MountPath: cons.LogMountPath,
Name: broker.Spec.VolumeClaimTemplates[0].Name,
SubPath: cons.LogSubPathName + getPathSuffix(broker, brokerGroupIndex, replicaIndex),
}, {
MountPath: cons.StoreMountPath,
Name: broker.Spec.VolumeClaimTemplates[0].Name,
SubPath: cons.StoreSubPathName + getPathSuffix(broker, brokerGroupIndex, replicaIndex),
}, {
MountPath: cons.BrokerConfigPath + "/" + cons.BrokerConfigName,
Name: broker.Spec.Volumes[0].Name,
SubPath: cons.BrokerConfigName,
}}
if len(broker.Spec.Volumes) > 1 && broker.Spec.Volumes[1].Name == "plain-acl" {
mounts = append(mounts, corev1.VolumeMount{
MountPath: cons.BrokerPlainAclConfigPath + "/" + cons.BrokerPlainAclConfigName,
Name: broker.Spec.Volumes[1].Name,
SubPath: cons.BrokerPlainAclConfigName,
})
}
return mounts
}

func getENV(broker *rocketmqv1alpha1.Broker, replicaIndex int, brokerGroupIndex int) []corev1.EnvVar {
envs := []corev1.EnvVar{{
Name: cons.EnvNameServiceAddress,
Expand Down