对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。

配置对 Atlas 的访问

要连接APIAtlas , Atlas Kubernetes Operator会从Atlas Kubernetes Operator密钥中读取组织ID和API密钥。您还可以配置以下功能:

要学习;了解有关创建Atlas帐户的更多信息,请参阅 注册并登录Atlas。

根据您的配置, Atlas Kubernetes Operator会读取以下Atlas Kubernetes Operator密钥之一:

范围
地点
说明

全局

在安装Atlas Kubernetes <operator-deployment-name>-api-keyOperator 的同一命名空间中创建的 Atlas Atlas Kubernetes Operator密钥 。

除非 AtlasProject 自定义资源 指定 spec.connectionSecretRef.name.,否则 Atlas Kubernetes Operator 使用此密钥数据连接到 Atlas 管理 API。

global Atlas Kubernetes Operator secrets let you use one API key for all the projects in an organization. Any new AtlasProject Custom Resource uses the same API key for reduced overhead.

Atlas Kubernetes Operator部署的默认名称是 mongodb-atlas-operator。因此,密钥 应命名为 mongodb-atlas-operator-api-key。

项目

密钥,并通过 spec.connectionSecretRef.name 在 Atlas Kubernetes Operator AtlasProject 自定义资源中引用。

默认下, Atlas Kubernetes Operator将连接密钥保存在与 AtlasProject自定义资源相同的命名空间中。要将密钥存储在其他命名空间中,请指定spec.connectionSecretRef。命名空间参数。

Atlas Kubernetes Operator使用此密钥数据连接到引用该项目的任何AtlasDeployment 自定义资源和 AtlasDatabaseUser 自定义资源的Atlas API 。

如果不指定spec.connectionSecretRef.name,Atlas Kubernetes Operator将使用global Atlas Kubernetes Operator密钥。

每个项目的 Atlas Kubernetes Operator 密钥允许更细粒度的访问。您可能需要使用单个 API 密钥来访问单个 Atlas 项目。

global 和 project 密钥 都需要以下信息:

Parameter
说明

orgId

24string用于标识Atlas 组织 的唯一 位十六进制 。

publicAPIKey

privateAPIKey

您需要以下公共 API 密钥、私有 API 密钥和组织 ID 信息, 配置 Atlas Kubernetes Operator 对 Atlas 的访问权限。

如需配置 Atlas Kubernetes Operator 访问 Atlas,请执行以下步骤之一。

  • 对于 global Atlas Kubernetes Operator 密钥,运行以下命令:

    注意

    global Atlas Kubernetes Operator密钥的名称必须符合预定义的格式。Atlas Kubernetes Operator部署的默认名称是 mongodb-atlas-operator。因此,密钥 应命名为 mongodb-atlas-operator-api-key。

    kubectl create secret generic mongodb-atlas-operator-api-key \ --from-literal="orgId=<the_atlas_organization_id>" \ --from-literal="publicApiKey=<the_atlas_api_public_key>" \ --from-literal="privateApiKey=<the_atlas_api_private_key>" \ -n <operator_namespace> kubectl label secret mongodb-atlas-operator-api-key atlas.mongodb.com/type=credentials -n mongodb-atlas-system
  • 对于 project Atlas Kubernetes Operator 密钥,运行以下命令:

    kubectl create secret generic my-project-connection \ --from-literal="orgId=<the_atlas_organization_id>" \ --from-literal="publicApiKey=<the_atlas_api_public_key>" \ --from-literal="privateApiKey=<the_atlas_api_private_key>" \ -n <atlas_project_namespace> kubectl label secret mongodb-atlas-operator-api-key atlas.mongodb.com/type=credentials -n mongodb-atlas-system