要连接到Atlas Administration API, Atlas Kubernetes Operator会从Atlas Kubernetes Operator密钥中读取组织ID和凭证。您可以使用API密钥或服务帐户进行身份验证。您还可以配置以下功能:
To learn more about creating an Atlas account, see Register and Log in to Atlas.
Atlas Kubernetes Operator 密钥
根据您的配置, Atlas Kubernetes Operator会读取以下Atlas Kubernetes Operator密钥之一:
范围 | 地点 | 说明 |
|---|---|---|
全局 | 在安装Atlas Kubernetes | 除非
Atlas Kubernetes Operator部署的默认名称是 |
项目 | 密钥,并通过 spec.connectionSecretRef.name 在 Atlas Kubernetes Operator 默认下, Atlas Kubernetes Operator将连接密钥保存在与 | Atlas Kubernetes Operator使用此密钥数据连接到引用该项目的任何 如果不指定spec.connectionSecretRef.name,Atlas Kubernetes Operator将使用 每个项目的 Atlas Kubernetes Operator 秘钥允许更细粒度的访问。您可能需要使用单个凭证集来访问单个 Atlas 项目。 |
参数
global 和 project 密钥 都需要以下信息:
Parameter | 说明 |
|---|---|
| 24string用于标识Atlas 组织 的唯一 位十六进制 。 |
| Public part of the API key. |
| Private part of the API key. |
Parameter | 说明 |
|---|---|
| 24string用于标识Atlas 组织 的唯一 位十六进制 。 |
| 服务帐户的客户端 ID。 |
| 服务帐户的客户端秘钥。创建后无法检索此值。 |
要了解有关服务账户的更多信息,请参阅 使用服务账户配置 Atlas 的访问权限。
先决条件
选择以下身份验证方法之一:
您需要以下公共 API 密钥、私有 API 密钥和组织 ID 信息, 配置 Atlas Kubernetes Operator 对 Atlas 的访问权限。
If you want Atlas Kubernetes Operator to create a new Atlas project, Grant Programmatic Access to an Organization. If your organization requires an IP access list for the Atlas Administration API, you must also configure the API access list.
重要
您必须为 API 密钥分配 Organization Project Creator 或更高级别的组织角色。
If you want to work with an existing Atlas project, Add Project Access from a Project. If your organization requires an IP access list for the Atlas Administration API, you must also configure the API access list.
重要
您必须为 API 密钥分配 Project Owner 项目角色。
您需要具有相应角色和组织 ID 的服务账户,才能配置 Atlas Kubernetes Operator 对 Atlas 的访问权限。
如果希望 Atlas Kubernetes Operator 创建新的 Atlas 项目,请创建具有“组织项目创建者”角色或更高角色的服务账户。
如果要使用现有 Atlas 项目,请创建具有 Project Owner 角色的服务帐户。
To learn how to create a Service Account, see Service Accounts Overview.
步骤
要配置 Atlas Kubernetes Operator 访问 Atlas,请使用您的凭证创建 秘密。选择与您偏好的身份验证方法匹配的标签页:
对于
globalAtlas Kubernetes Operator 密钥,运行以下命令:注意
globalAtlas 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 对于
projectAtlas 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 my-project-connection atlas.mongodb.com/type=credentials -n <atlas_project_namespace>
对于
globalAtlas Kubernetes Operator 密钥,运行以下命令:注意
globalAtlas Kubernetes Operator密钥的名称必须符合预定义的格式。Atlas Kubernetes Operator部署的默认名称是mongodb-atlas-operator。因此,密钥 应命名为mongodb-atlas-operator-service-account。kubectl create secret generic mongodb-atlas-operator-service-account \ --from-literal="orgId=<the_atlas_organization_id>" \ --from-literal="clientId=<the_service_account_client_id>" \ --from-literal="clientSecret=<the_service_account_client_secret>" \ -n <operator_namespace> kubectl label secret mongodb-atlas-operator-service-account atlas.mongodb.com/type=credentials -n mongodb-atlas-system 对于
projectAtlas Kubernetes Operator 密钥,运行以下命令:kubectl create secret generic my-project-connection \ --from-literal="orgId=<the_atlas_organization_id>" \ --from-literal="clientId=<the_service_account_client_id>" \ --from-literal="clientSecret=<the_service_account_client_secret>" \ -n <atlas_project_namespace> kubectl label secret my-project-connection atlas.mongodb.com/type=credentials -n <atlas_project_namespace>
要了解如何使用 Atlas Kubernetes Operator 配置服务账户,请参阅使用服务账户配置对 Atlas 的访问。