Docs Menu
Docs Home
/
MongoDB Enterprise Kubernetes 演算子

Kubernetes 演算子のクイック スタート

項目一覧

  • 前提条件
  • 手順
  • Kubernetes 用 の MongoDB Helm Charts を追加する Helm へのリポジトリを使用します。
  • MongoDB Enterprise Kubernetes Operatorのインストール
  • kubectlをデフォルトで名前空間に設定します。
  • Kubernetes 演算子の構成
  • ConfigMap をコピーして保存します。
  • シークレットをコピーして保存します。
  • ConfigMap と シークレット を適用します。
  • レプリカセットリソースを配置します。
  • データベースユーザーのパスワードを使用してシークレットを作成する
  • データベースユーザーを作成します。
  • 任意: Cloud ManagerまたはMongoDB Ops Managerで新しく作成されたユーザーを表示します。
  • レプリカセットに接続します。

重要

このセクションは、単一の Kubernetes クラスターの配置のみを対象としています。 マルチ Kubernetes クラスターの MongoDB 配置については、 マルチKubernetes クラスター クイック スタート を参照してください。

MongoDB Enterprise Kubernetes Operator は、Kubernetes API とツールを使用して MongoDB クラスターを管理します。 Kubernetes Operator は、 MongoDB Cloud ManagerまたはMongoDB Ops Managerと連携します。 このチュートリアルでは、Kubernetes Operator を使用して MongoDB Cloud Manager に最初のレプリカセットを配置して接続する方法を説明します。 種類を使用してクラスターをすばやく設定できます。 詳しくは、 の 種類 を参照してください。 。

このチュートリアルには次のものが必要です。

1
helm repo add mongodb https://mongodb.github.io/helm-charts
2

Helm Charts で Kubernetes Operator をインストールするには については、 リポジトリの手順を参照してください。

次のコマンドは、任意の--create-namespaceオプションを使用して、 mongodb名前空間に MongoDB Enterprise Kubernetes Operator をインストールします。 デフォルトでは、Kubernetes Operator はdefault名前空間を使用します。

helm install enterprise-operator mongodb/enterprise-operator --namespace mongodb --create-namespace
3

まだ作成していない場合は、次のコマンドを実行して、作成した名前空間ですべてのkubectlコマンドを実行します。

kubectl config set-context $(kubectl config current-context) --namespace=mongodb
4
  1. UIGo の [Kubernetes 設定] ページに します。Cloud Manager

  2. [ Create New API KeysまたはUse Existing API Keysをクリックします。

  3. フォームを完了します。 詳細については、 「プログラムによる Cloud Manager へのアクセス 」を参照してください。

  4. [Generate Key and YAML] をクリックします。

5

生成されたconfig-map.yamlファイルをコピーして保存します。

例:

apiVersion: v1
kind: ConfigMap
metadata:
name: my-project
namespace: mongodb
data:
baseUrl: https://cloud.mongodb.com
projectName: my-project # this is an optional parameter
orgId: 5ecd252f8c1a75033c74106c # this is a required parameter

詳しくは、パラメーターの説明を参照してください。

6

生成されたsecret.yamlファイルをコピーして保存します。

例:

apiVersion: v1
kind: Secret
metadata:
name: organization-secret
namespace: mongodb
stringData:
user: <public_key>
publicAPIKey: <private_key>

セキュリティ上の理由から、MongoDB Cloud Manager はこのファイルを 1 回だけ表示します。

7

次のコマンドを実行します:

kubectl apply -f secret.yaml -f config-map.yaml
8
  1. 次のYAMLファイルをコピーして保存します。

    apiVersion: mongodb.com/v1
    kind: MongoDB
    metadata:
    name: demo-mongodb-cluster-1
    namespace: mongodb
    spec:
    members: 3
    version: 4.4.5-ent
    type: ReplicaSet
    security:
    authentication:
    enabled: true
    modes: ["SCRAM"]
    cloudManager:
    configMapRef:
    name: my-project
    credentials: organization-secret
    persistent: true
    podSpec:
    podTemplate:
    spec:
    containers:
    - name: mongodb-enterprise-database
    resources:
    limits:
    cpu: 2
    memory: 1.5G
    requests:
    cpu: 1
    memory: 1G
    persistence:
    single:
    storage: 10Gi
  2. 次のコマンドを実行します:

    kubectl apply -f <replica-set-conf>.yaml
9

クリアテキスト パスワードまたは base64 でエンコードされたパスワードのどちらかを使用できます。 プレーンテキスト パスワードではstringData.passwordが使用され、Base64 でエンコードされたパスワードではdata.passwordが使用されます。

注意

次のパラメーターに値を指定します。 詳しくは、パラメーターの説明を参照してください。

クリアテキスト パスワードの場合は、次のYAMLファイルを作成して保存します。

apiVersion: v1
kind: Secret
metadata:
name: mms-user-1-password
# corresponds to user.spec.passwordSecretKeyRef.name
type: Opaque
stringData:
password: <my-plain-text-password>
# corresponds to user.spec.passwordSecretKeyRef.key

base64 でエンコードされたパスワードの場合は、次の YAML ファイルを作成して保存します。

apiVersion: v1
kind: Secret
metadata:
name: mms-user-1-password
# corresponds to user.spec.passwordSecretKeyRef.name
type: Opaque
data:
password: <base-64-encoded-password>
# corresponds to user.spec.passwordSecretKeyRef.key
10
  1. 次のMongoDB ユーザー リソース仕様ファイルをコピーして保存します。

    apiVersion: mongodb.com/v1
    kind: MongoDBUser
    metadata:
    name: mms-scram-user-1
    spec:
    passwordSecretKeyRef:
    name: mms-user-1-password
    # Match to metadata.name of the User Secret
    key: password
    username: "mms-scram-user-1"
    db: "admin" #
    mongodbResourceRef:
    name: "demo-mongodb-cluster-1"
    # Match to MongoDB resource using authenticaiton
    roles:
    - db: "admin"
    name: "clusterAdmin"
    - db: "admin"
    name: "userAdminAnyDatabase"
    - db: "admin"
    name: "readWrite"
    - db: "admin"
    name: "userAdminAnyDatabase"
  2. 次のコマンドを実行します:

    kubectl apply -f <database-user-conf>.yaml
11

新しく作成されたユーザーは、 Cloud ManagerまたはMongoDB Ops Managerで表示できます。

  1. プロジェクトのDeploymentビューから、 Securityタブをクリックします。

  2. [ MongoDB Users ] ネストされたタブをクリックします。

12

Cloud Managerアプリケーションで次の手順を実行します。

  1. 左側のナビゲーションで [ Deployment ] をクリックします。

  2. をクリックします接続する配置の 。

  3. [Connect to this instance] をクリックします。

  4. 配置に接続するには、ターミナルで接続コマンドを実行します。

戻る

MongoDB Enterprise Kubernetes 演算子