KubeBlocks
BlogsSkillsEnterprise
⌘K
​
Blogs

Overview
Quickstart
Architecture

Operations

Stop / Start / Restart
Vertical Scaling
Horizontal Scaling
Volume Expansion
Reconfigure
Manage Services

Observability

Prometheus Integration
  1. Resource Hierarchy
  2. Containers Inside Each Pod
    1. NameServer Pods
    2. Broker Pods
    3. Exporter Pods
    4. Dashboard Pods
  3. Component Roles
    1. NameServer
    2. Broker
  4. High Availability: ASYNC_MASTER/SLAVE Replication
  5. Traffic Routing
  6. Automatic Failover
  7. System Accounts

RocketMQ Architecture in KubeBlocks

This page describes how KubeBlocks deploys an Apache RocketMQ cluster on Kubernetes — covering the resource hierarchy, NameServer and Broker component roles, master/slave HA, and traffic routing.

Producer / Consumer
Application
Publish / subscribe via RocketMQ SDK
Connects to NameServer for route discovery
RocketMQ SDK
route discovery → broker direct connect
NameServer (Service Discovery) · :9876
namesrv-0
:9876 · Route table for all brokers
Stateless — scale horizontally
Pod
namesrv-1
:9876 · Route table for all brokers
Stateless — scale horizontally
Pod
broker register → route lookup
Broker Shards · :10911 (DLedger Raft HA — 2 shards shown)
Shard 0DLEDGER
⚙️
broker-0-0
:10911 · Raft leader
Leader
⚙️
broker-0-1
:10911 · Raft follower
Follower
Shard 1DLEDGER
⚙️
broker-1-0
:10911 · Raft leader
Leader
⚙️
broker-1-1
:10911 · Raft follower
Follower
⬡DLedger RaftEach shard runs independent Raft consensus — leader failure triggers automatic re-election within the shard; surviving majority continues serving writes
Observability & Dashboard
Exporter
Prometheus metrics on :5557
Broker JMX sidecar on :5556
Metrics
Dashboard
Web admin console · :8080
Access via port-forward 18080:8080
Web UI
RocketMQ Broker / NameServer
Raft Leader
Raft Follower / Observability
Client Traffic

Resource Hierarchy

KubeBlocks models a RocketMQ cluster as a hierarchy of Kubernetes custom resources:

Cluster  →  Component (namesrv)   →  InstanceSet  →  Pod × N
         →  Sharding  (broker)    →  Shard × N    →  InstanceSet  →  Pod × replicas
         →  Component (exporter)  →  InstanceSet  →  Pod × 1
         →  Component (dashboard) →  InstanceSet  →  Pod × 1
ResourceRole
ClusterUser-facing declaration — specifies the topology, replica counts for each component, storage, and resources
Component (namesrv)Generated automatically; references the NameServer ComponentDefinition; stateless routing registry
Sharding (broker)KubeBlocks Sharding resource backed by a ShardingDefinition; manages N independent broker groups (shards), each with its own replica set
Component (exporter)Prometheus metrics bridge — scrapes RocketMQ metrics from brokers via NameServer and exposes them on port 5557
Component (dashboard)Web management console — provides a UI for topics, consumers, and brokers; exposes HTTP on port 8080
InstanceSetKubeBlocks custom workload (replaces StatefulSet); manages pods with stable identities and role awareness
PodActual running RocketMQ process; each pod gets a unique ordinal and its own PVC (except dashboard which uses emptyDir)

The ClusterDefinition topology master-slave defines all four components with the following lifecycle order:

  • Provision: namesrv → broker → exporter → dashboard
  • Terminate: dashboard → exporter → broker → namesrv
  • Update: namesrv → broker → exporter → dashboard

A RocketMQ cluster consists of NameServer (service discovery) and Broker (message storage) as the core data-plane components, with exporter (metrics) and dashboard (web console) as optional management-plane components — all four are part of the default master-slave topology.

Containers Inside Each Pod

NameServer Pods

ContainerPortPurpose
rocketmq-namesrv9876 (TCP)RocketMQ NameServer — maintains topic routing information; acts as a service registry for brokers and clients
jmx-exporter5556Prometheus JMX metrics exporter

Broker Pods

ContainerPortPurpose
rocketmq-broker10911 (remoting), 10909 (vip-channel), 10912 (HA replication), 40911 (DLedger/Raft)RocketMQ Broker — stores message queues, handles producer/consumer requests, and replicates data within a broker group; roleProbe runs /scripts/get-role.sh inside this container
jmx-exporter5556Prometheus JMX metrics exporter
agent8999Lightweight HTTP server for topic and subscription group info

Each Broker pod mounts its own PVC for the message store directory (/home/rocketmq/store), providing persistent storage for commit logs and consume queues.

Exporter Pods

ContainerPortPurpose
rocketmq-exporter5557 (metrics)Scrapes RocketMQ metrics via NameServer and exposes them in Prometheus format; connects to brokers using admin credentials

Dashboard Pods

ContainerPortPurpose
rocketmq-dashboard8080 (console)RocketMQ web management console — view and manage topics, consumer groups, and broker status; uses emptyDir for configuration (no PVC)

Component Roles

NameServer

NameServer is a lightweight, stateless routing registry. Each NameServer instance is independent — there is no leader election or data replication between NameServer nodes. Producers and consumers connect to all known NameServer instances and use any available one for routing lookups:

NameServer ResponsibilityDescription
Broker registrationBrokers register their topic routing information with all NameServer instances at startup and periodically
Topic routing queriesProducers and consumers query NameServer to discover which brokers host the topics they need
Stale broker detectionNameServer removes brokers that have not sent a heartbeat within 120 seconds

Broker

Brokers are organized into broker groups (a master plus N slaves). Each group handles a distinct set of topic partitions:

Broker RoleDescription
Master brokerAccepts producer writes; assigned brokerId=0 at startup; optionally serves consumer reads
Slave brokerReplicates from the master via the HA replication port (10912); assigned brokerId≥1; serves consumer reads when configured

High Availability: ASYNC_MASTER/SLAVE Replication

KubeBlocks deploys RocketMQ brokers in ASYNC_MASTER/SLAVE mode by default. Each broker group has one master (brokerId=0) and one or more slaves that replicate asynchronously from the master via port 10912. The role assignment is determined at startup by broker-setup.sh based on the pod's ordinal index.

ConceptDescription
Master brokerAccepts all producer writes; the only member that can confirm message durability
Slave brokerReplicates the master's commit log asynchronously via port 10912; serves consumer reads
HA replicationSlaves maintain a persistent connection to the master on port 10912 for log replication
QuorumNone — async replication; acknowledged writes are durable only on the master
NOTE

DLedger (Raft) mode is an optional alternative that provides automatic master election via Raft consensus. It requires setting ENABLE_DLEDGER=true in the broker container environment. This environment variable is not set in the KubeBlocks RocketMQ add-on by default, so DLedger is not active unless explicitly configured.

Traffic Routing

KubeBlocks creates services for NameServer. Broker has no ClusterIP service by default — the cmpd-broker ComponentDefinition contains no services block, so the broker controller creates only a headless service per shard:

ServiceTypePortNotes
{cluster}-namesrvClusterIP9876All NameServer pods; clients use this for topic routing lookups
{cluster}-namesrv-headlessHeadless9876All NameServer pods; always created by the workload controller
{cluster}-<shard>-headlessHeadless10911, 10912, 10909Per broker shard; all pods in the shard; used for HA replication and operator probes — no broker ClusterIP exists by default
{cluster}-dashboardClusterIP8080Dashboard web console; named default in the ComponentDefinition with no explicit serviceName, resolving to {cluster}-{component}

Producers and consumers connect to NameServer (port 9876) at startup to fetch topic routing information. NameServer returns the direct pod addresses of broker masters — clients then connect to brokers directly using these addresses, bypassing any ClusterIP. HA replication traffic between broker replicas flows over port 10912 via the per-shard headless service.

The exec roleProbe (/scripts/get-role.sh) detects each broker's role and updates the kubeblocks.io/role pod label; this drives KubeBlocks rolling update ordering (master updated last) but does not affect service routing since there is no broker ClusterIP service.

Automatic Failover

When a RocketMQ component fails:

  1. NameServer failure — producers/consumers switch to another available NameServer instance; NameServer instances are independent so no election is required
  2. Broker master failure — slaves detect the missing master heartbeat; writes to the affected broker group are unavailable; slaves continue serving consumer reads from their local replica
  3. KubeBlocks pod restart — KubeBlocks detects the failed pod and restarts it; the recovered pod resumes as master (brokerId=0) after the process starts
  4. Master re-registers — the recovered master re-registers with all NameServer instances; topic routing is refreshed
  5. Slaves reconnect — slaves re-establish the HA replication connection to the restored master on port 10912 and resync any missed log entries

System Accounts

The RocketMQ add-on declares KubeBlocks systemAccounts on the broker and Dashboard ComponentDefinitions. NameServer and other components do not use this mechanism in the same way. Passwords are generated according to each account’s policy unless overridden on the Cluster.

Secrets follow {cluster}-{component}-account-{accountName} — where {component} is each component’s name in the Cluster spec (for example dashboard for the Dashboard, and each broker shard component name such as broker-0, broker-1, …).

AccountComponent (typical)RolePurpose
rocketmq-adminPer broker shard (broker-*)Broker admin / ACL userInjected into broker pods as ROCKETMQ_USER and ROCKETMQ_PASSWORD for broker authentication configuration
console-admindashboardDashboard loginInjected into Dashboard pods as CONSOLE_USER and CONSOLE_PASSWORD for the RocketMQ Dashboard web UI

The Dashboard also needs the broker admin identity to talk to the cluster: it reads rocketmq-admin credentials from the broker ComponentDefinition via credentialVarRef (same username/password as the broker shard’s rocketmq-admin account).

© 2026 KUBEBLOCKS INC