# MongoDB 应用用户密码示例（请改为更安全的值，或对接外部 Secret 管理）
apiVersion: v1
kind: Secret
metadata:
  name: mongodb-app-user-password
  namespace: juwan # 示例业务命名空间
type: Opaque
stringData:
  password: ChangeMe123456 # 示例明文，仅用于演示
---
# MongoDB Community Operator 自定义资源示例
apiVersion: mongodbcommunity.mongodb.com/v1
kind: MongoDBCommunity
metadata:
  name: juwan-mongodb
  namespace: juwan
spec:
  members: 3 # 副本集成员数，生产建议保持奇数
  type: ReplicaSet
  version: "7.0.12" # MongoDB 版本
  security:
    authentication:
      modes:
        - SCRAM # 启用用户名密码认证
  users:
    - name: app-user # 业务账号
      db: admin
      passwordSecretRef:
        name: mongodb-app-user-password # 引用上方 Secret
      roles:
        - name: readWrite
          db: appdb # 对 appdb 库授予读写
      scramCredentialsSecretName: app-user-scram # Operator 生成的凭据 Secret
  additionalMongodConfig:
    # 示例：开启 WiredTiger 日志压缩
    storage.wiredTiger.engineConfig.journalCompressor: zlib
