Docs Menu
Docs Home
/
MongoDB Enterprise Kubernetes 演算子
/

OpenShift クイック スタート

項目一覧

重要

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

MongoDB Enterprise Kubernetes Operator は、Kubernetes API とツールを使用して MongoDB クラスターを管理します。 Kubernetes Operator は、 MongoDB Cloud ManagerまたはMongoDB Ops Managerと連携します。 このチュートリアルでは、Cloud Manager MongoDB Ops ManagerOpenShiftKubernetesOperator を使用して から または の最初のレプリカセットに最初のレプリカセットを配置して接続する方法を説明します。

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

  • 実行中のCloud ManagerまたはMongoDB Ops Managerクラスター。

1
git clone https://github.com/mongodb/mongodb-enterprise-kubernetes.git
2

デフォルトでは、Kubernetes 演算子は mongodb名前空間を使用します。 インストールを簡素化するために、次のmongodb kubernetes を使用して というラベルの付いた名前空間を作成することを検討してください コマンド:

kubectl create namespace mongodb
3

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

kubectl config set-context $(kubectl config current-context) --namespace=mongodb
4
  1. 次の OC を呼び出します CustomResourceDefinitions をインストールするコマンド MongoDB 配置の場合

    oc apply -f crds.yaml
  2. MongoDB Enterprise Kubernetes Operator YAMLファイルのServiceAccount定義に<openshift-pull-secret>を追加します。

    ---
    # Source: mongodb-enterprise-operator/templates/serviceaccount.yaml
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
    name: enterprise-operator
    namespace: mongodb
    imagePullSecrets:
    - name: <openshift-pull-secret>
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
    name: mongodb-enterprise-appdb
    namespace: mongodb
    imagePullSecrets:
    - name: <openshift-pull-secret>
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
    name: mongodb-enterprise-database-pods
    namespace: mongodb
    imagePullSecrets:
    - name: <openshift-pull-secret>
  3. 次の OC を呼び出します Kubernetes Operator をインストールするためのコマンド

    oc apply -f mongodb-enterprise-openshift.yaml
5

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

注意

次のパラメーターに公開キーの値と秘密キーの値を指定します。 詳細については、「 Kubernetes Operator の認証情報の作成 」を参照してください。

kubectl -n mongodb \
create secret generic ops-manager-admin-key \
--from-literal="publicKey=<publicKey>" \
--from-literal="privateKey=<privateKey>"
6
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: my-project
namespace: mongodb
data:
projectName: myProjectName # this is an optional parameter; when omitted, the Operator creates a project with the resource name
orgId: 5b890e0feacf0b76ff3e7183 # this is a required parameter
baseUrl: https://ops.example.com:8443
EOF
キー
タイプ
説明
metadata.name
string

Kubernetes オブジェクト の名前 。

リソース名は 44 文字以下にする必要があります。

詳細については、「 名前 」に関する Kubernetes のドキュメントを参照してください。 。この名前は RFC1123 -.に従う必要があります。 命名規則」では、小文字の英数字のみを使用し、 または を使用し、先頭と末尾には英数字を使用する必要があります。

my-project
metadata.namespace
string
Kubernetes 名前空間 Kubernetes Operator がこのMongoDB リソースと他の オブジェクト を作成する 。
mongodb
data.projectName
string

MongoDB Ops Managerプロジェクトのラベル。

Kubernetes Operator は、 MongoDB Ops Managerプロジェクトが存在しない場合は、それを作成します。 projectNameを省略すると、Kubernetes Operator は Kubernetes リソースと同じ名前のプロジェクトを作成します。

または 組織で既存のプロジェクトを使用するには、Cloud Manager MongoDB Ops ManagerprojectNameAll ClustersまたはCloud ManagerMongoDB Ops Manager ページの左上にあるSearch {1 リンクをクリックし、次で名前を検索して、 を見つけます。 ボックスまたはスクロールして、リスト内の名前を見つけます。このリストの各カードは、1 つのCloud ManagerまたはMongoDB Ops Managerの組織プロジェクトの組み合わせを表します。

myProjectName
data.orgId
string

必須。 または 組織 を一意に識別する24 文字の 16stringCloud Manager MongoDB Ops Manager進 。

Kubernetes演算子を使用して、MongoDB Cloud ManagerMongoDB Ops Managerおよび バージョン6.0 .x 以降で リソースを配置できます。

Atlas 演算子を使用して、MongoDB リソースを Atlas に配置できます。

既存の組織を指定します:

  1. 組織の ID を見つけます。

    左側のナビゲーション バーで [ Settingsをクリックします。

  2. orgId をコピーして URL に貼り付けます。

    次のように、組織を選択し、ブラウザで現在のURLを表示し、 <orgId>プレースホルダーに表示される値をコピーします。

    https://ops.example.com:8443/ v2#/org/<orgId>/projects

既存の Cloud Managerまたは 組織内に新しいプロジェクトを作成するには、 組織プロジェクト作成者MongoDB Ops Manager ロールが必要です。

orgId として空のstringを指定すると、 Kubernetes Operator はプロジェクトと同じ名前の組織を作成します。

5b890e0feacf0b76ff3e7183
data.baseUrl
string

FQDN とポート番号を含む MongoDB Ops Manager アプリケーションへの URL 。

重要: を Operator で配置し、 MongoDB Ops Managerが配置先のKubernetes クラスターのMongoDB Ops Manager MongoDB外部 に配置された データベースリソースを管理する場合、Kubernetesdata.baseUrlspec.configuration.mms.centralUrl の 設定と同じ値に設定する必要があります。 のリソース仕様。MongoDB Ops Manager詳細については、「外部MongoDBデプロイの管理 」を参照してください。

Cloud Manager を使用している場合は、 data.baseUrlの値をhttps://cloud.mongodb.comに設定します。

https://ops.example.com:8443
7
  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
8

クリアテキスト パスワードまたは 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
9
  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
10

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

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

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

11

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

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

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

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

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

戻る

OpenShift チュートリアル