Make the MongoDB docs better! We value your opinion. Share your feedback for a chance to win $100.
MongoDB Branding Shape
Click here >
Docs 菜单

配置对 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密钥允许您为组织中的所有项目使用一个API密钥。任何新的 AtlasProject自定义资源都使用相同的API密钥,以减少开销。

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

项目

密钥,并通过 spec.connectionSecretRef.nameAtlas 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 项目。

globalproject 密钥 都需要以下信息:

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