Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pulsar manager v0.2.0 with jwt setup admin account creation #219

5 changes: 5 additions & 0 deletions .ci/chart_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ VALUES_FILE=$1
TLS=${TLS:-"false"}
SYMMETRIC=${SYMMETRIC:-"false"}
FUNCTION=${FUNCTION:-"false"}
MANAGER=${MANAGER:-"false"}

source ${PULSAR_HOME}/.ci/helm.sh

Expand All @@ -40,6 +41,10 @@ if [[ "x${SYMMETRIC}" == "xtrue" ]]; then
extra_opts="-s"
fi

if [[ "x${EXTRA_SUPERUSERS}" != "x" ]]; then
extra_opts="${extra_opts} --pulsar-superusers proxy-admin,broker-admin,admin,${EXTRA_SUPERUSERS}"
fi

install_type="install"
test_action="produce-consume"
if [[ "$UPGRADE_FROM_VERSION" != "" ]]; then
Expand Down
7 changes: 7 additions & 0 deletions .ci/clusters/values-jwt-asymmetric.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.
#


auth:
authentication:
enabled: true
Expand All @@ -35,3 +36,9 @@ auth:
proxy: "proxy-admin"
# pulsar-admin client to broker/proxy communication
client: "admin"
# pulsar-manager to broker communication
manager: "manager-admin"

components:
pulsar_manager: true

6 changes: 6 additions & 0 deletions .ci/clusters/values-jwt-symmetric.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.
#


auth:
authentication:
enabled: true
Expand All @@ -35,3 +36,8 @@ auth:
proxy: "proxy-admin"
# pulsar-admin client to broker/proxy communication
client: "admin"
# pulsar manager to broker
manager: "manager-admin"

components:
pulsar_manager: true
1 change: 1 addition & 0 deletions .ci/clusters/values-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.
#


# enable TLS
tls:
enabled: true
Expand Down
26 changes: 22 additions & 4 deletions .ci/helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function ci::install_pulsar_chart() {
local install_type=$1
local common_value_file=$2
local value_file=$3
local extra_opts=$4
local extra_opts="$4 $5 $6 $7 $8"
local install_args

if [[ "${install_type}" == "install" ]]; then
Expand Down Expand Up @@ -374,19 +374,37 @@ function ci::test_pulsar_manager() {
-sS -D headers.txt \
-d '{"username": "pulsar", "password": "'${PASSWORD}'"}'
LOGIN_TOKEN=$(${KUBECTL} exec -n ${NAMESPACE} ${podname} -- grep "token:" headers.txt | sed 's/^.*: //')
LOGIN_JSESSSIONID=$(${KUBECTL} exec -n ${NAMESPACE} ${podname} -- grep -o "JSESSIONID=[a-zA-Z0-9_]*" headers.txt | sed 's/^.*=//')
LOGIN_JSESSIONID=$(${KUBECTL} exec -n ${NAMESPACE} ${podname} -- grep -o "JSESSIONID=[a-zA-Z0-9_]*" headers.txt | sed 's/^.*=//')

echo "Checking environment"
envs=$(${KUBECTL} exec -n ${NAMESPACE} ${podname} -- curl -X GET http://localhost:9527/pulsar-manager/environments \
-H 'Content-Type: application/json' \
-H "token: $LOGIN_TOKEN" \
-H "X-XSRF-TOKEN: $CSRF_TOKEN" \
-H "username: pulsar" \
-H "Cookie: XSRF-TOKEN=$CSRF_TOKEN; JSESSIONID=$LOGIN_JSESSSIONID;")
-H "Cookie: XSRF-TOKEN=$CSRF_TOKEN; JSESSIONID=$LOGIN_JSESSIONID;")
echo "$envs"
number_of_envs=$(echo $envs | jq '.total')
if [ "$number_of_envs" -ne 1 ]; then
echo "Error: Did not find expected environment"
exit 1
fi
}

# Force manager to query broker for tenant info. This will require use of the manager's JWT, if JWT authentication is enabled.
echo "Checking tenants"
pulsar_env=$(echo $envs | jq -r '.data[0].name')
tenants=$(${KUBECTL} exec -n ${NAMESPACE} ${podname} -- curl -X GET http://localhost:9527/pulsar-manager/admin/v2/tenants \
-H 'Content-Type: application/json' \
-H "token: $LOGIN_TOKEN" \
-H "X-XSRF-TOKEN: $CSRF_TOKEN" \
-H "username: pulsar" \
-H "tenant: pulsar" \
-H "environment: ${pulsar_env}" \
-H "Cookie: XSRF-TOKEN=$CSRF_TOKEN; JSESSIONID=$LOGIN_JSESSIONID;")
echo "$tenants"
number_of_tenants=$(echo $tenants | jq '.total')
if [ "$number_of_tenants" -lt 1 ]; then
echo "Error: Found no tenants!"
exit 1
fi
}
4 changes: 4 additions & 0 deletions .github/workflows/pulsar-helm-chart-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ jobs:
case "${{ matrix.testScenario.shortname }}" in
"jwt-symmetric")
export SYMMETRIC=true
export EXTRA_SUPERUSERS=manager-admin
;;
"jwt-asymmetric")
export EXTRA_SUPERUSERS=manager-admin
;;
esac
if [[ "${{ matrix.testScenario.type || 'install' }}" == "upgrade" ]]; then
Expand Down
3 changes: 1 addition & 2 deletions charts/pulsar/templates/broker-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,10 @@ data:
authenticationEnabled: "true"
{{- if .Values.auth.authorization.enabled }}
authorizationEnabled: "true"
superUserRoles: {{ .Values.auth.superUsers | values | sortAlpha | join "," }}
superUserRoles: {{ .Values.auth.superUsers | values | compact | 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: 2 additions & 2 deletions charts/pulsar/templates/proxy-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ data:
authorizationEnabled: "false"
forwardAuthorizationCredentials: "true"
{{- if .Values.auth.useProxyRoles }}
superUserRoles: {{ omit .Values.auth.superUsers "proxy" | values | sortAlpha | join "," }}
superUserRoles: {{ omit .Values.auth.superUsers "proxy" | values | compact | sortAlpha | join "," }}
{{- else }}
superUserRoles: {{ .Values.auth.superUsers | values | sortAlpha | join "," }}
superUserRoles: {{ .Values.auth.superUsers | values | compact | sortAlpha | join "," }}
{{- end }}
{{- end }}
{{- if eq .Values.auth.authentication.provider "jwt" }}
Expand Down
52 changes: 50 additions & 2 deletions charts/pulsar/templates/pulsar-manager-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ spec:
volumeMounts:
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}-{{ .Values.pulsar_manager.volumes.data.name }}"
mountPath: /data
{{- if .Values.auth.authentication.enabled }}
{{- if eq .Values.auth.authentication.provider "jwt" }}
- name: pulsar-manager-keys
mountPath: /pulsar-manager/keys
{{- end }}
{{- end }}
envFrom:
- configMapRef:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}"
Expand All @@ -87,8 +93,50 @@ spec:
key: DB_PASSWORD
- name: PULSAR_MANAGER_OPTS
value: "$(PULSAR_MANAGER_OPTS) -Dlog4j2.formatMsgNoLookups=true"
{{- include "pulsar.imagePullSecrets" . | nindent 6 }}
{{- if .Values.auth.authentication.enabled }}
{{- if eq .Values.auth.authentication.provider "jwt" }}
{{- if .Values.auth.superUsers.manager }}
- name: JWT_TOKEN
valueFrom:
secretKeyRef:
key: TOKEN
name: "{{ .Release.Name }}-token-{{ .Values.auth.superUsers.manager }}"
{{- end }}
{{- if .Values.auth.authentication.jwt.usingSecretKey }}
- name: SECRET_KEY
value: file:///pulsar-manager/keys/token/secret.key
{{- else }}
- name: PRIVATE_KEY
value: file:///pulsar-manager/keys/token/private.key
- name: PUBLIC_KEY
value: file:///pulsar-manager/keys/token/public.key
{{- end }}
{{- end }}
{{- end }}
{{- include "pulsar.imagePullSecrets" . | nindent 6}}
volumes:
{{- if .Values.auth.authentication.enabled }}
{{- if eq .Values.auth.authentication.provider "jwt" }}
- name: pulsar-manager-keys
secret:
defaultMode: 420
{{- if .Values.auth.authentication.jwt.usingSecretKey }}
secretName: "{{ .Release.Name }}-token-symmetric-key"
{{- else }}
secretName: "{{ .Release.Name }}-token-asymmetric-key"
{{- end }}
items:
{{- if .Values.auth.authentication.jwt.usingSecretKey }}
- key: SECRETKEY
path: token/secret.key
{{- else }}
- key: PRIVATEKEY
path: token/private.key
- key: PUBLICKEY
path: token/public.key
{{- end }}
{{- end }}
{{- end }}
{{- if not (and (and .Values.persistence .Values.volumes.persistence) .Values.pulsar_manager.volumes.persistence) }}
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}-{{ .Values.pulsar_manager.volumes.data.name }}"
emptyDir: {}
Expand All @@ -113,4 +161,4 @@ spec:
{{- end }}
{{- end }}

{{- end }}
{{- end }}
8 changes: 2 additions & 6 deletions charts/pulsar/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ auth:
proxy: "proxy-admin"
# pulsar-admin client to broker/proxy communication
client: "admin"
# pulsar-manager to broker communication. If left empty, no jwt setup will be performed in the manager
manager: ""
# 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
Expand Down Expand Up @@ -1311,12 +1313,6 @@ pulsar_manager:
DRIVER_CLASS_NAME: org.postgresql.Driver
URL: jdbc:postgresql://127.0.0.1:5432/pulsar_manager
LOG_LEVEL: DEBUG
## If you enabled authentication support
## JWT_TOKEN: <token>
## SECRET_KEY: data:base64,<secret key>

# the pulsar manager image relies on these variables, if they are not set the backend will keep crashing
# however, feel free to overwrite them
SPRING_CONFIGURATION_FILE: "/pulsar-manager/pulsar-manager/application.properties"
PULSAR_MANAGER_OPTS: " -Dlog4j2.formatMsgNoLookups=true"
volumes:
Expand Down
Loading