为了让Kubernetes Operator 在Cloud Manager或MongoDB Ops Manager项目中创建或更新对象,您需要将编程API密钥存储在密钥存储工具中。
同一个命名空间中可以存在多个密钥。 每个用户都应该有自己的密钥。
您可以按照以下 步骤 手动将 编程 API 密钥 存储为 Kubernetes 密钥 。或者,您可以:
Store the Programmatic API Key as a Vault secret using the procedure to Create a Vault Secret. To use Vault, you must also configure the secret storage.
先决条件
要为 Kubernetes 操作符 创建档案,您必须:
拥有或创建MongoDB Ops Manager组织。
拥有或生成编程API密钥。
授予此新的编程 API 密钥:
The Organization Owner or
Global Ownerrole, if you want the Kubernetes Operator to create projects and manage them.项目所有者角色(如果您希望 Kubernetes Operator 仅管理项目)。
注意
You must grant the Programmatic API Key the Organization Owner or
Global Ownerrole. If you want to grant the Programmatic API Key only the Project Owner role, you must first create the project and then the Programmatic API Key for the project with the Project Owner role. The Kubernetes Operator can't create projects if the Programmatic API Key has only the Project Owner role.将任何为Kubernetes Operator提供服务的主机的IP或CIDR区块添加到API访问列表中。
步骤
要创建 Kubernetes 密钥,请执行以下操作:
创建新的 Kubernetes 密钥
确保您拥有所需 Ops Manager 编程 API 密钥的公钥和私钥。
调用以下 Kubernetes 命令来创建密钥:
kubectl -n <metadata.namespace> \ create secret generic <mycredentials> \ --from-literal="publicKey=<publicKey>" \ --from-literal="privateKey=<privateKey>" -n标志限制了此密钥适用的命名空间。所有MongoDB Kubernetes资源必须与密钥和ConfigMap位于同一命名空间中。Kubernetes Operator 不使用密钥或 ConfigMap。注意
此命令的已弃用版本会指定
user和publicApiKey,而不是publicKey和privateKey。 Kubernetes 操作符接受任一版本的身份验证。