Kubernetes Operator がCloud ManagerまたはMongoDB Ops Managerプロジェクト内のオブジェクトを作成または更新するには、プログラマティックAPIキーをシークレットストレージツールに保存する必要があります。
複数のシークレットが同じ名前空間に存在できます。 各ユーザーには独自のシークレットが必要です。
以下の 手順 に従って、 プログラマティック API キー を Kubernetes secret として手動で保存できます。 。または、次のこともできます。
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 Operator の認証情報を作成するには、次の手順を実行する必要があります。
MongoDB Ops Manager組織を または 作成します。
プログラマティックAPIキーを取得または生成します。
この新しいプログラマティック API キーを付与します。
Global OwnerKubernetes Operator でプロジェクトを作成し、それらを管理する場合の組織オーナーまたは ロール。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 シークレットを作成する
目的のMongoDB Ops ManagerプログラマティックAPIキーの公開キーと秘密キーがあることを確認してください。
次の Kubernetes コマンドを呼び出してシークレットを作成します。
kubectl -n <metadata.namespace> \ create secret generic <mycredentials> \ --from-literal="publicKey=<publicKey>" \ --from-literal="privateKey=<privateKey>" フラグは 名前空間 を制限します このシークレットが適用される
-nすべての MongoDB Kubernetes リソースは シークレット と同じ名前空間に存在する必要があります と ConfigMaps 。Kubernetes Operator は、シークレットも ConfigMap も使用しません。注意
このコマンドの非推奨バージョンでは、
publicKeyとprivateKeyではなく、userとpublicApiKeyが指定されます。 Kubernetes Operator は認証にどちらのバージョンも受け入れます。
新しい Kubernetes シークレットを確認する
次の Kubernetes コマンドを呼び出して、シークレットを検証します。
kubectl describe secrets/<mycredentials> -n <metadata.namespace>
このコマンドは、shell 内のシークレットの説明を返します。
Name: <mycredentials> Namespace: <metadata.namespace> Labels: <none> Annotations: <none> Type: Opaque Data ==== privateKey: 31 bytes publicKey: 22 bytes