CLI: Cluster & Brokers
Every command supports --output json for scripting and --help for usage details. Set the broker endpoint via environment variable or flag:
export DANUBE_BROKER_ENDPOINT=http://localhost:50051# or per command:danube-admin --broker-endpoint http://broker1:50051 brokers listCluster (Raft)
Section titled “Cluster (Raft)”The cluster commands manage the Raft consensus layer that underpins Danube’s metadata replication. All metadata changes (topic assignments, namespace creation, schema registration) are replicated through Raft.
Status
Section titled “Status”Show current Raft cluster state including leader, term, voters, and learners.
danube-admin cluster statusRaft Cluster Status: Self Node ID: 9823746501928374 Raft Address: 127.0.0.1:7650 Leader: 9823746501928374 Term: 3 Last Applied: 142 Voters: [9823746501928374, 1048209374659182, 7391028374651029] Learners: [5829103746519283]| Field | Description |
|---|---|
| Self Node ID | The node ID of the broker you connected to |
| Raft Address | The Raft transport address (host:raft_port) |
| Leader | Node ID of the current leader (none if no leader elected) |
| Term | Current Raft term — monotonically increasing election counter |
| Last Applied | Index of the last log entry applied to the state machine |
| Voters | Node IDs that participate in consensus (quorum members) |
| Learners | Node IDs replicating the log but not yet voting |
Add Node
Section titled “Add Node”Add a new broker as a Raft learner (non-voting). The CLI auto-discovers the new node’s node_id and raft_addr by connecting to its admin endpoint first, then tells the leader to add it.
danube-admin cluster add-node --node-addr http://new-broker:50054| Option | Required | Description |
|---|---|---|
--node-addr | Yes | Admin gRPC endpoint of the new broker |
Discovering node at http://new-broker:50054... Discovered: node_id=5829103746519283, raft_addr=new-broker:7653Adding node 5829103746519283 as learner via http://127.0.0.1:50051...Success: Node 5829103746519283 added as learnerThe new broker must already be running with its Raft port accessible. Learners replicate the Raft log but do not participate in votes. After adding, use promote-node to grant voting rights.
Promote Node
Section titled “Promote Node”Promote a Raft learner to a full voting member (voter).
danube-admin cluster promote-node --node-id <NODE_ID>Promoting node 5829103746519283 to voter...Success: Node 5829103746519283 promoted to voterAfter promotion the node participates in consensus votes and counts toward quorum. For production clusters, activate the broker after promoting so it can receive topic assignments:
danube-admin brokers activate <BROKER_ID>Remove Node
Section titled “Remove Node”Remove a node from the Raft cluster entirely.
danube-admin cluster remove-node --node-id <NODE_ID>Scale-Up Workflow
Section titled “Scale-Up Workflow”# 1. Check current cluster statedanube-admin cluster status
# 2. Add the new broker as a learnerdanube-admin cluster add-node --node-addr http://new-broker:50054
# 3. Verify it appears as a learnerdanube-admin cluster status
# 4. Promote to voterdanube-admin cluster promote-node --node-id <NODE_ID>
# 5. Activate the broker so it receives topicsdanube-admin brokers activate <BROKER_ID>
# 6. Verify cluster balancedanube-admin brokers balanceScale-Down Workflow
Section titled “Scale-Down Workflow”# 1. Drain all topics from the brokerdanube-admin brokers unload <BROKER_ID>
# 2. Remove from the Raft clusterdanube-admin cluster remove-node --node-id <NODE_ID>
# 3. Verify cluster statedanube-admin cluster status
# 4. Stop the broker process (external)Brokers
Section titled “Brokers”Manage broker nodes, load distribution, and maintenance operations.
List Brokers
Section titled “List Brokers”Display all brokers in the cluster with their details.
danube-admin brokers list┌──────────────┬─────────────────────┬──────────┬─────────────────────┬─────────────────────┬────────┐│ Broker ID │ Address │ Role │ Admin Address │ Metrics Address │ Status │├──────────────┼─────────────────────┼──────────┼─────────────────────┼─────────────────────┼────────┤│ broker-001 │ 127.0.0.1:6650 │ leader │ 127.0.0.1:50051 │ 127.0.0.1:9090 │ active ││ broker-002 │ 127.0.0.1:6651 │ follower │ 127.0.0.1:50052 │ 127.0.0.1:9091 │ active │└──────────────┴─────────────────────┴──────────┴─────────────────────┴─────────────────────┴────────┘[ { "broker_id": "broker-001", "broker_addr": "127.0.0.1:6650", "broker_role": "leader", "admin_addr": "127.0.0.1:50051", "metrics_addr": "127.0.0.1:9090", "broker_status": "active" }]Get Leader
Section titled “Get Leader”Identify which broker is currently the cluster leader. The leader coordinates cluster operations and is the primary target for admin commands.
danube-admin brokers leaderList Namespaces
Section titled “List Namespaces”danube-admin brokers namespacesCluster Balance
Section titled “Cluster Balance”Show cluster balance metrics and broker load distribution.
danube-admin brokers balance╔══════════════════════════════════════════════════════════╗║ Cluster Balance Report ║╚══════════════════════════════════════════════════════════╝
Status: ✅ Well BalancedCoefficient of Variation: 15.23%Assignment Strategy: Balanced
Load Statistics: Mean Load: 4.50 Max Load: 5.00 Min Load: 4.00 Std Deviation: 0.50 Broker Count: 2
Broker Details:Broker ID Load Topics Status--------------------------------------------------broker-001 5.00 5 OKbroker-002 4.00 4 OKCoefficient of Variation (CV) measures load distribution uniformity. Lower is better:
| CV | Status | Action |
|---|---|---|
| < 20% | Well Balanced | None needed |
| 20–30% | Balanced | Acceptable |
| 30–40% | Imbalanced | Consider rebalancing |
| > 40% | Severely Imbalanced | Rebalance recommended |
Load is the topic count weighted by topic activity and resource usage.
Rebalance
Section titled “Rebalance”Manually trigger cluster rebalancing to distribute topics evenly across brokers.
# Preview moves without executing (always do this first)danube-admin brokers rebalance --dry-run
# Execute rebalancingdanube-admin brokers rebalance
# Limit scope for gradual rebalancingdanube-admin brokers rebalance --max-moves 10| Option | Description | Default |
|---|---|---|
--dry-run | Preview proposed moves without executing | false |
--max-moves | Maximum number of topic moves | All necessary |
🔍 Dry-Run Mode: Preview only, no changes will be applied
Proposed Moves: 3
Topic From To--------------------------------------------------/default/events broker-001 broker-002/default/logs broker-001 broker-002/default/metrics broker-001 broker-003
Load Before Rebalancing: broker-001: 8 topics (Overloaded) broker-002: 2 topics (Underloaded) broker-003: 2 topics (Underloaded)
Expected Load After Rebalancing: broker-001: 5 topics (OK) broker-002: 4 topics (OK) broker-003: 3 topics (OK)
💡 Run without --dry-run to execute these moves✅ Rebalancing Complete!
Moves Executed: 3Topic Movements: ✓ /default/events: broker-001 → broker-002 ✓ /default/logs: broker-001 → broker-002 ✓ /default/metrics: broker-001 → broker-003
💡 Run 'danube-admin brokers balance' to verify cluster stateRecommended workflow:
danube-admin brokers balance # 1. Check current balancedanube-admin brokers rebalance --dry-run # 2. Preview movesdanube-admin brokers rebalance # 3. Executedanube-admin brokers balance # 4. Verify resultsUnload Broker
Section titled “Unload Broker”Gracefully drain all topics from a broker for maintenance or decommissioning.
danube-admin brokers unload <BROKER_ID>Unload Started: trueTotal Topics: 45Succeeded: 45Failed: 0Pending: 0| Option | Description | Default |
|---|---|---|
--dry-run | Preview topics to be unloaded | false |
--max-parallel | Number of topics to unload concurrently | 1 |
--namespace-include | Only unload topics from these namespaces (repeatable) | All |
--namespace-exclude | Skip topics from these namespaces (repeatable) | None |
--timeout | Timeout per topic (seconds) | 30 |
# Preview what would be unloadeddanube-admin brokers unload broker-001 --dry-run
# Parallel unload with namespace filterdanube-admin brokers unload broker-001 \ --max-parallel 5 \ --namespace-include default \ --namespace-include analytics \ --timeout 30Activate Broker
Section titled “Activate Broker”Mark a broker as active, allowing it to receive traffic and topic assignments.
danube-admin brokers activate <BROKER_ID> --reason "Maintenance completed"Common Workflows
Section titled “Common Workflows”Health Check
Section titled “Health Check”danube-admin cluster status # Raft consensus statedanube-admin brokers list # All brokers and their statusdanube-admin brokers leader # Current leaderdanube-admin brokers balance # Load distributionBroker Maintenance
Section titled “Broker Maintenance”# 1. Preview what will be draineddanube-admin brokers unload broker-001 --dry-run
# 2. Drain topics from the brokerdanube-admin brokers unload broker-001
# 3. Perform maintenance (upgrade, config change, etc.)
# 4. Reactivate the brokerdanube-admin brokers activate broker-001 --reason "Maintenance completed"
# 5. Rebalance if neededdanube-admin brokers balancedanube-admin brokers rebalance --dry-runCluster Expansion
Section titled “Cluster Expansion”# 1. Start the new broker process (external)
# 2. Add to Raft as learnerdanube-admin cluster add-node --node-addr http://new-broker:50054
# 3. Promote to voterdanube-admin cluster promote-node --node-id <NODE_ID>
# 4. Activate for trafficdanube-admin brokers activate <BROKER_ID> --reason "New broker added"
# 5. Rebalance topics across all brokersdanube-admin brokers rebalancedanube-admin brokers balance