CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

Redpanda CLI (rpk)

$ rpk 官方出品 中风险
Redpanda Data · 数据库与数据处理 · BSL-1.1 · macos / linux / windows

rpk 是 Redpanda 官方一体化 CLI,同时兼容 Redpanda 与 Apache Kafka 集群。可管理 Topic、消费者组、ACL、Schema Registry 与 Connect 管道,并提供结构化 --format json / -f json 输出以及标准输入输出流式读写。

FCRS-1.0 综合评分
87 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install redpanda-data/tap/redpanda
CLI vs MCP 选型建议 优先选 CLI

rpk 可直接在 Shell 管道中流式消费与过滤消息(rpk topic consume -f '%v\n' -n 10 | jq),兼容任意 Kafka/Redpanda 集群。

Agent 友好度体检单

✓ 原生 JSON 输出
✓ 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
— 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 23 / 25

cluster info、topic list、topic consume 与 group describe 均支持 --format json,并可通过 --num 限定读取条数。

  • Supports --format json / -f json across admin and consume commands
  • --num <N> prevents topic consume from hanging in non-TTY shells
安全与权限边界 20 / 25

具备 Profile 隔离与 SASL/TLS 支持,但 topic delete、group offset-delete 等破坏性命令缺少 --dry-run。

  • Named profiles in rpk.yaml isolate clusters
  • No global --dry-run on topic delete or ACL deletions
安装与运行摩擦 13 / 15

单一二进制,可通过 Homebrew tap 与官方压缩包安装于 macOS 与 Linux(Windows 可通过 WSL 或二进制运行)。

  • Standalone binary via brew install redpanda-data/tap/redpanda
能力覆盖与边际价值 14 / 15

用单一高速二进制替代零散的 kafka-topics.sh、kafka-console-consumer.sh 与 Schema Registry 脚本。

  • Covers brokers, topics, ACLs, groups, and Schema Registry
维护与来源背书 9 / 10

Redpanda Data 一方维护(redpanda-data/redpanda),版本迭代迅速。

  • Official Redpanda Data repository
文档与可验证性 8 / 10

docs.redpanda.com 提供详尽的 rpk 命令与 --format 模板参考文档。

  • Full rpk command reference at docs.redpanda.com

安全边界、鉴权与放权指南

鉴权方式
本地配置文件 环境变量密钥
凭证存储位置

在 ~/.config/rpk/rpk.yaml 中保存集群 Profile 与 SASL/TLS 配置,也支持 --brokers、RPK_BROKERS 及 --user/--password 参数。

潜在副作用
只读查询 本地写入 远端写入 破坏性删除
费用与配额提示

BSL-1.1 源码可用协议(4 年后自动转为 Apache-2.0),作为 CLI 客户端免费使用。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# Redpanda CLI (rpk) Agent Rules
- Always pass `--format json` on `cluster`, `topic list`, and `group` read commands.
- ALWAYS bound `rpk topic consume` with `--num <N>` or `--offset end` so the command exits instead of hanging.
- Never run `rpk topic delete` or `rpk group delete` without explicit user confirmation.

Agent 高频安全命令配方

只读查询(安全推荐)

以 JSON 查看集群元数据与节点信息
rpk cluster info --format json

返回包含集群 ID、Broker 列表与 Topic 摘要的结构化 JSON。

按条数限制安全采样 Topic 消息
rpk topic consume orders --num 10 --format json

精确读取 10 条 JSON 消息(--num 10)后自动退出,避免无限阻塞。

受控写入与预演

向 Topic 发送单条 JSON 事件
echo '{"id":1,"status":"ok"}' | rpk topic produce orders

从标准输入读取单行记录并写入 orders Topic。

核心优势

  • + --format json 贯穿集群、Topic、ACL 与消费命令。
  • + rpk topic consume --num <N> 让消息采样具有确定性且不会阻塞。
  • + 同时兼容标准 Apache Kafka 与 Redpanda 集群。

注意事项与踩坑点

  • ! 核心仓库采用 BSL-1.1 源码可用协议(4 年后转为 Apache-2.0)。
  • ! 调用 rpk topic consume 若遗漏 --num 将持续阻塞等待,导致 Agent 工具调用超时。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI