Why Use Istio with Pulsar
Deploying Pulsar with Istio provides:- Enhanced Security: Automatic mTLS encryption for service-to-service communication
- Traffic Management: Advanced routing, load balancing, and traffic control
- Observability: Built-in metrics, logging, and distributed tracing
- External Access: Unified ingress gateway for all protocols (Pulsar, Kafka, MQTT, AMQP)
- Policy Enforcement: Fine-grained authorization policies
Prerequisites
Istio Requirements
-
Istio Installation: Istio installed in your Kubernetes cluster
- Tested with Istio 1.24.2 and earlier versions
- Use the default revision or adjust according to your Istio setup
- Default trust domain is
cluster.local, adjust if needed
-
Istio Ingress Gateway: Must be installed and configured
- Service type must be
LoadBalancer - Required port mappings:
443->8443: HTTP/HTTPS6651->6651: Pulsar with TLS9093->9093: Kafka with TLS5671->5671: AMQP with TLS8883->8883: MQTT with TLS
- Service type must be
TLS Certificate
- A TLS certificate secret exists in the Istio Ingress Gateway namespace
- Covers your endpoint domain (e.g.,
pulsar.example.com) - Covers per-broker domains (e.g.,
pb0-pulsar.example.com,pb1-pulsar.example.com, etc.) - Alternative: A wildcard certificate is used (e.g.,
*.example.com)
DNS Configuration
- DNS records point to the Ingress Gateway LoadBalancer IP
- Main endpoint:
pulsar.example.com - Per-broker endpoints:
pb0-pulsar.example.com,pb1-pulsar.example.com, up topb${replicas-1}-pulsar.example.com - Alternative: Wildcard DNS
*.example.comis configured
If the StreamNative Operator is not Istio sidecar injected, configure the
cloud.streamnative.io/ignore-leader-check: "true" annotation on the ZooKeeperCluster resource.Deploy Pulsar Cluster
For a complete working example, see the Pulsar with Istio example in the StreamNative Private Cloud repository.Istio-Specific Configuration
Add the following Istio configurations to your Pulsar components:PulsarCoordinator
Configure the Istio revision and trust domain for the cluster:ZooKeeperCluster
Enable Istio with mTLS:If the StreamNative Operator is not Istio sidecar injected, add this annotation:
BookKeeperCluster
Enable Istio with mTLS:PulsarBroker
Enable Istio with mTLS and Gateway configuration for external access:spec.istio.enabled: Enables Istio integrationspec.istio.mtls.mode: mTLS mode (strict,permissive, ornone)spec.istio.revision: Istio revision to usespec.istio.gateway.selector: Label selector for the Istio Ingress Gatewayspec.istio.gateway.tls.certSecretName: Name of the TLS certificate secretspec.istio.gateway.tls.mode: TLS mode (simplefor standard TLS)spec.config.advertisedDomain: Domain for external accessspec.config.serviceURLGenerationPolicy: Set toOrdinalPrefixfor per-broker routing
Istio Resources Created
When you enable Istio for the PulsarBroker, the StreamNative Operator automatically creates several Istio resources to secure and expose your cluster: Security Resources:- PeerAuthentication: Enforces mutual TLS (mTLS) between services within the mesh. Configurable in
strictmode (reject non-mTLS connections) orpermissivemode (accept both mTLS and plaintext during migration). - DestinationRule: Configures client-side TLS settings for service-to-service communication, automatically enabling
ISTIO_MUTUALmode for broker internal services. - AuthorizationPolicy: Defines fine-grained access control rules, allowing traffic from specific service accounts and the Istio ingress gateway.
- Gateway: Exposes brokers externally through the Istio Ingress Gateway, with support for both cluster-level and per-pod access. Handles TLS termination or passthrough based on your configuration.
- VirtualService: Routes incoming traffic from the Gateway to the appropriate broker pods based on hostname and protocol (Pulsar, Kafka, MQTT, AMQP, HTTP).
- ServiceEntry: Creates DNS entries for individual broker pods (e.g.,
pb0-pulsar.example.com,pb1-pulsar.example.com), enabling Pulsar clients to discover and connect to specific brokers.
All Istio resources are managed automatically by the operator. You only need to configure the
spec.istio section in your custom resources. The operator handles creation, updates, and deletion of all related Istio resources.Verify Deployment
Check Pod Status
Verify that all pods are running with Istio sidecars (2/2 containers):Get Service Endpoints
Get the service endpoints from the PulsarBroker status:- Admin:
http://private-cloud-broker.pulsar.svc.cluster.local:8080 - Pulsar:
pulsar://private-cloud-broker.pulsar.svc.cluster.local:6650
- Admin:
https://pulsar.example.com - Pulsar TLS:
pulsar+ssl://pulsar.example.com:6651
Test Connectivity
Test Within Kubernetes Cluster
Test Pulsar using the toolset created by the StreamNative Operator or any Istio-injected pod:Test Outside Kubernetes Cluster
Test Pulsar using TLS from outside the cluster:Istio Ambient Mode
Starting with sn-operator v0.13, you can deploy Pulsar with Istio ambient mode — a sidecarless data plane architecture that replaces per-pod Envoy sidecars with a shared node-level ztunnel DaemonSet.Benefits
- Reduced mesh overhead: No per-pod sidecar containers (saves ~100MB memory + 0.1 CPU per pod)
- Eliminates startup delays: No sidecar injection or init container waits before the application starts
- Simpler operations: New pods join the mesh via labels without sidecar injection
- Full feature parity: All Istio resources (Gateway, VirtualService, PeerAuthentication, AuthorizationPolicy) continue to work
Ambient mode uses ztunnel for L4 mTLS only. L7 features such as HTTP routing and TLS termination are handled by the existing Istio Gateway, which has its own Envoy proxy. No waypoint proxy is needed for Pulsar workloads.
Prerequisites
- Istio 1.24+ with ambient mode enabled and the ztunnel DaemonSet running on your cluster. Refer to the Istio Ambient Mode documentation for installation and configuration instructions specific to your environment.
Configure Ambient Mode
To configure ambient mode, setdataplaneMode: ambient on the PulsarCoordinator. The operator propagates this setting to all managed components (PulsarBroker, PulsarProxy, BookKeeperCluster, ZooKeeperCluster) automatically via server-side apply.
PulsarCoordinator
Add the followingdataplaneMode field to the existing spec.istio section of your PulsarCoordinator resource:
dataplaneMode to all managed component CRDs. If you manage components individually without a PulsarCoordinator, add the same field directly to each component’s spec.istio section.
Configuration reference:
| Field | Values | Description |
|---|---|---|
spec.istio.dataplaneMode | ambient or sidecar | Data plane mode. Defaults to sidecar if not set |
Verify Ambient Mode Deployment
Verify that pods are running without sidecars (1/1 containers instead of 2/2):ambient for each pod:
Migrate from Sidecar to Ambient Mode
To migrate an existing sidecar-mode cluster to ambient mode:- Ensure Istio 1.24+ with ambient mode is running in your cluster.
-
Update the PulsarCoordinator (replace
<name>with your PulsarCoordinator resource name and<namespace>with the Pulsar namespace): -
Monitor the rolling update by checking that each component CR reaches ready state:
Wait until the
READY REPLICAScolumn matchesREPLICASfor each component. - Verify ambient enrollment (see Verify Ambient Mode Deployment above).
During the rolling update, mTLS is maintained. Istio supports interoperability between ztunnel (ambient) and sidecar proxies, so old and new pods can communicate throughout the migration.
dataplaneMode back to sidecar and restore any namespace-level sidecar injection labels (e.g., istio-injection=enabled or istio.io/rev=<revision>) that were previously removed.
Ambient Mode Troubleshooting
| Symptom | Cause | Solution |
|---|---|---|
| Pods still show 2/2 containers | Sidecar still injected | Verify dataplaneMode: ambient is set and pods have restarted |
Pods missing istio.io/dataplane-mode label | Setting not propagated | Check PulsarCoordinator spec and component CRD specs |
| mTLS not working | ztunnel not running | Verify kubectl get daemonset -n istio-system ztunnel shows pods on all nodes |
| Gateway routing not working | Gateway resource misconfigured | Check Gateway and VirtualService resources — these work the same in ambient mode |
Enable Protocol Handlers
After deploying the base Pulsar cluster with Istio, you can enable additional protocol handlers:- Configure Kafka Protocol - Enable Kafka protocol support
- Configure MQTT Protocol - Enable MQTT protocol support
- Configure AMQP Protocol - Enable AMQP 0-9-1 protocol support