Before you begin
Generate the RSA256 key pair and tokens
Usepulsarctl to generate an RSA256 key pair:
broker-admin and proxy-admin subjects using the private key:
client subject:
Create Kubernetes Secrets for keys and tokens
Only the public key goes into Kubernetes. The private key must never be stored as a cluster Secret.-
Create the public key Secret:
-
Create the
broker-admintoken Secret: -
Create the
proxy-admintoken Secret:
<broker-admin-token> and <proxy-admin-token> with the tokens generated in the previous step.
Enable JWT authentication for the Pulsar cluster
Add the following configurations to thePulsarBroker object:
config.clientAuth: configures the toolset to mount and use the broker-admin token automatically.config.custom: sets Pulsar authentication and authorization properties.pod.secretRefs: mounts the public key Secret as a file inside the pod.pod.vars: exposes the public key path and broker-admin token as environment variables for Pulsar configuration.
PulsarProxy object, add the following configurations:
config.custom: sets Pulsar authentication and authorization properties.pod.secretRefs: mounts the public key Secret as a file inside the pod.pod.vars: exposes the public key path and broker-admin token as environment variables for Pulsar configuration.
Connect clients to Pulsar
-
Create authorization for the client subject using the
broker-admintoken:Expected output: -
Produce messages with the client token:
-
Consume messages with the client token:
Verify the configuration
After the pods restart, confirm the broker is using the public key and not a shared secret:tokenSecretKey must be empty. If it is set, the broker is using symmetric auth instead of RS256.
Configure Pulsar console
TheConsole CRD does not have a native plain-JWT field. Authentication is configured by injecting environment variables directly via pod.vars and mounting the public key via pod.secretRefs.
A single dedicated service account (consoleservice) is used for both the Console backend connection to the broker and the web login. This subject must be in superUserRoles on the broker so it can perform all admin operations, including listing clusters.
Issue the Console service account token
Issue a dedicated RS256 token for theconsoleservice subject:
<consoleservice-token> with the token generated above.
Add the Console service account to the broker
Update thePulsarBroker object to include consoleservice in superUserRoles:
Configure the Console CRD
Add the following to theConsole object: