Skip to content

Commit

Permalink
Support configuring "proxyRoles" in broker (#430)
Browse files Browse the repository at this point in the history
* Add support for proxyRoles

* Test produce and consume via Pulsar proxy
  • Loading branch information
lhotari authored Jan 16, 2024
1 parent e54354d commit f20756a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .ci/helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ function ci::install_pulsar_chart() {
# ${KUBECTL} exec -n ${NAMESPACE} ${CLUSTER}-toolset-0 -- bash -c 'until [ "$(curl -L http://pulsar-ci-proxy:8080/status.html)" == "OK" ]; do sleep 3; done'
}

helm_values_cached=""

function ci::helm_values_for_deployment() {
if [[ -z "${helm_values_cached}" ]]; then
helm_values_cached=$(helm get values -n ${NAMESPACE} ${CLUSTER} -a -o yaml)
fi
printf "%s" "${helm_values_cached}"
}

function ci::test_pulsar_producer_consumer() {
sleep 120
${KUBECTL} exec -n ${NAMESPACE} ${CLUSTER}-toolset-0 -- bash -c 'until nslookup pulsar-ci-broker; do sleep 3; done'
Expand All @@ -178,6 +187,14 @@ function ci::test_pulsar_producer_consumer() {
${KUBECTL} exec -n ${NAMESPACE} ${CLUSTER}-toolset-0 -- bin/pulsar-admin topics create-subscription -s test pulsar-ci/test/test-topic
${KUBECTL} exec -n ${NAMESPACE} ${CLUSTER}-toolset-0 -- bin/pulsar-client produce -m "test-message" pulsar-ci/test/test-topic
${KUBECTL} exec -n ${NAMESPACE} ${CLUSTER}-toolset-0 -- bin/pulsar-client consume -s test pulsar-ci/test/test-topic
${KUBECTL} exec -n ${NAMESPACE} ${CLUSTER}-toolset-0 -- bin/pulsar-admin topics create-subscription -s test2 pulsar-ci/test/test-topic
if [[ "$(ci::helm_values_for_deployment | yq .tls.proxy.enabled)" == "true" ]]; then
PROXY_URL="pulsar+ssl://pulsar-ci-proxy:6651"
else
PROXY_URL="pulsar://pulsar-ci-proxy:6650"
fi
${KUBECTL} exec -n ${NAMESPACE} ${CLUSTER}-toolset-0 -- bin/pulsar-client --url "${PROXY_URL}" produce -m "test-message2" pulsar-ci/test/test-topic
${KUBECTL} exec -n ${NAMESPACE} ${CLUSTER}-toolset-0 -- bin/pulsar-client --url "${PROXY_URL}" consume -s test2 pulsar-ci/test/test-topic
}

function ci::wait_function_running() {
Expand Down
4 changes: 4 additions & 0 deletions charts/pulsar/templates/broker-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ data:
{{- if .Values.auth.authorization.enabled }}
authorizationEnabled: "true"
superUserRoles: {{ .Values.auth.superUsers | values | sortAlpha | join "," }}
{{- if .Values.auth.useProxyRoles }}
proxyRoles: {{ .Values.auth.superUsers.proxy }}
{{- end }}

{{- end }}
{{- if eq .Values.auth.authentication.provider "jwt" }}
# token authentication configuration
Expand Down
4 changes: 4 additions & 0 deletions charts/pulsar/templates/proxy-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ data:
# disable authorization on proxy and forward authorization credentials to broker
authorizationEnabled: "false"
forwardAuthorizationCredentials: "true"
{{- if .Values.auth.useProxyRoles }}
superUserRoles: {{ omit .Values.auth.superUsers "proxy" | values | sortAlpha | join "," }}
{{- else }}
superUserRoles: {{ .Values.auth.superUsers | values | sortAlpha | join "," }}
{{- end }}
{{- end }}
{{- if eq .Values.auth.authentication.provider "jwt" }}
# token authentication configuration
authenticationProviders: "org.apache.pulsar.broker.authentication.AuthenticationProviderToken"
Expand Down
3 changes: 3 additions & 0 deletions charts/pulsar/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ auth:
proxy: "proxy-admin"
# pulsar-admin client to broker/proxy communication
client: "admin"
# omits the above proxy role from superusers on the proxy
# and configures it as a proxy role on the broker in addition to the superusers
useProxyRoles: true

######################################################################
# External dependencies
Expand Down

0 comments on commit f20756a

Please sign in to comment.