KubeBlocks
BlogsEnterprise
⌘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. Component Roles
    1. NameServer
    2. Broker
  4. High Availability via DLedger (Raft)
  5. Traffic Routing
  6. Automatic Failover

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, DLedger-based HA, and traffic routing.

Resource Hierarchy

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

Cluster  →  Component  →  InstanceSet  →  Pod × N
ResourceRole
ClusterUser-facing declaration — specifies the topology, replica counts for each component, storage, and resources
ComponentGenerated automatically; one Component per role (NameServer, Broker); references a ComponentDefinition
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

A RocketMQ cluster consists of two distinct component types: NameServer (service discovery and routing registry) and Broker (message storage and delivery). These map to separate KubeBlocks Components within the same Cluster.

Containers Inside Each Pod

NameServer Pods

ContainerPortPurpose
namesrv9876 (TCP)RocketMQ NameServer — maintains topic routing information; acts as a service registry for brokers and clients
kbagent5001Role probe endpoint
metrics-exporter9187Prometheus metrics exporter

Broker Pods

ContainerPortPurpose
broker10911 (remoting), 10912 (HA replication)RocketMQ Broker — stores message queues, handles producer/consumer requests, and replicates data within a broker group
kbagent5001Role probe endpoint — identifies broker role (master/slave)
metrics-exporter9187Prometheus metrics exporter

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

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; optionally serves consumer reads depending on read preference
Slave brokerReplicates from the master via the HA replication port (10912); serves consumer reads when configured
DLedger masterIn DLedger mode, the elected Raft leader; handles all writes and replicates to DLedger followers

High Availability via DLedger (Raft)

KubeBlocks deploys RocketMQ brokers with DLedger mode enabled, which replaces the traditional master/slave replication with a Raft-based commit log:

DLedger ConceptDescription
DLedger leaderThe Raft leader in a broker group; all message writes go through the leader
DLedger followerReplicates log entries from the leader; participates in voting
Write quorumA majority of broker replicas must acknowledge a log entry before it is committed
Leader electionWhen the leader broker fails, surviving followers elect a new leader via Raft
Minimum replicas3 replicas per broker group are required for DLedger to function (tolerates 1 failure)

Traffic Routing

KubeBlocks creates services for both NameServer and Broker components:

ServiceTypePortSelector
{cluster}-namesrvClusterIP9876all NameServer pods
{cluster}-namesrv-headlessHeadless9876all NameServer pods
{cluster}-brokerClusterIP10911kubeblocks.io/role=master broker pods
{cluster}-broker-headlessHeadless10911, 10912all Broker pods

Producers and consumers connect to NameServer (port 9876) at startup to fetch topic routing information, then connect directly to the appropriate broker master using addresses obtained from NameServer. HA replication traffic between broker replicas flows over port 10912 via the headless 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 — DLedger detects the leader's absence; the remaining follower replicas elect a new Raft leader within seconds
  3. New master registers — the newly elected DLedger leader re-registers with all NameServer instances
  4. Producer/consumer reconnect — clients refresh routing from NameServer and resume sending to the new master
  5. KubeBlocks pod label update — the kbagent probe detects the new master; the kubeblocks.io/role=master label is applied to the new leader pod, and the Broker ClusterIP service Endpoints are updated accordingly

© 2026 KUBEBLOCKS INC