Skip to content

Commit

Permalink
[ISSUE #184] support plain acl configration
Browse files Browse the repository at this point in the history
  • Loading branch information
drivebyer committed Mar 13, 2024
1 parent 674666f commit b8c7b05
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
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 {
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

0 comments on commit b8c7b05

Please sign in to comment.