mongodb controllers for kubernetes operator 是当前唯一受支持的生产级部署方式,mongodb enterprise kubernetes operator 已于2026年正式弃用;必须使用新 helm 仓库 https://mongodb.github.io/helm-charts 下的 mongodb/mongodb-kubernetes chart,并配置 cloud manager/ops manager api key、强制启用 tls、显式设置 externalaccess 及 publishnotreadyaddress: true。

确认 Operator 版本和 Helm 仓库
别跳过这步——很多连接失败或 CRD 不生效的问题都源于用了旧仓库或废弃 chart。
- 必须使用新仓库:
https://mongodb.github.io/helm-charts,旧的stable/mongodb-enterprise等已失效 - 安装的是
mongodb/mongodb-kuberneteschart,不是mongodb/enterprise-operator(后者对应已弃用的旧 Operator) - 检查本地 Helm repo 是否更新:
helm repo update;若之前添加过旧源,先helm repo remove mongodb再重新 add
部署 Operator 前必须配置 Cloud Manager / Ops Manager API Key
Operator 启动后会立即尝试连接 Cloud Manager 或 Ops Manager(6.0.x+),没配好就卡在 Pending 状态,日志里反复报 Unauthorized 或 connection refused。
针对 Kubernetes 仪表板和 Web UI 的浏览器自动化。适用于与 Kubernetes Dashboard、Grafana、ArgoCD UI 或其他 Web 界面交互。需要设置 MCP_BROWSER_ENABLED=true。
- 登录 Cloud Manager UI → Kubernetes Settings → Generate Key and YAML
- 生成的
config-map.yaml必须提前 apply,且其中的baseUrl要能被 Operator Pod 访问(比如不能填localhost或内网不可达地址) - API Key 的权限需包含
Automation Administrator角色,仅Viewer会导致资源创建被拒绝
定义 MongoDBReplicaSet CR 时 TLS 是强制开关项
不显式声明 spec.security.tls.enabled,Operator 默认禁用 TLS——但 Cloud Manager 6.0.10+ 实际要求所有新副本集启用 TLS,否则部署会卡在 WaitingForAgent 状态。
- 若用自签名证书,必须同时提供:
spec.security.certsSecretPrefix(指向含ca.pem、server.pem等的 Secret)和spec.security.tls.ca(CA 公钥内容) - 若用 Let’s Encrypt 或云厂商证书,确保 Secret 中的 key 名为
tls.crt和tls.key,Operator 才能自动挂载 - 错误示例:
spec.security.tls.enabled: true但没配certsSecretPrefix→ Pod 启动失败,报错failed to load TLS certificate
外部访问必须显式配置 externalAccess
副本集成员默认只能在集群内 DNS 解析(如 mongo-0.mongo-svc.mongodb.svc.cluster.local),从外部应用连接时,光开 Service NodePort 没用——Operator 不会自动暴露成员地址。
- 必须在 CR 中设置:
externalAccess: {},否则 Operator 不创建 LoadBalancer 类型的外部服务 - 每个 Pod 会得到一个独立的
<pod-name>-svc-external</pod-name>Service,名称不可改,端口默认 27017 -
publishNotReadyAddress: true是硬性要求,设成false会导致 DNS 记录延迟生成,客户端首次连接超时
Failed to create automation config 才能看到真实原因。










