注意
This tutorial presumes some knowledge of Kubernetes. If you are unfamiliar with Kubernetes, review the Kubernetes documentation on Kubernetes objects and custom resources before you begin. The Kubernetes Operator represents Ops Manager and MongoDB deployments as custom resources. You create and manage them with kubectl in the same way that you manage any other Kubernetes object. To learn how these custom resources relate to each other, see MongoDB Controllers for Kubernetes Operator Architecture Overview.
前提条件
Kubernetes 演算子 をインストールする前に、次の前提条件を満たしてください。
使用可能な Kubernetes ソリューションを用意し、ハードウェア アーキテクチャのサポートを確認します。
Kubernetesソリューションが必要な場合は、 適切なソリューションの選択 に関するKubernetes のドキュメントを参照してください。サポートされているハードウェアアーキテクチャを確認します。
Clone the MongoDB Controllers for Kubernetes Operator repository.
git clone https://github.com/mongodb/mongodb-kubernetes.git
注意
Helm は使用できます Kubernetes Operator のインストールHelmGithub をインストールする方法については 、 のドキュメントを参照してください。
Create a namespace for your Kubernetes deployment.
デフォルトでは 、 Kubernetes演算子は mongodb名前空間を使用します。インストールを簡素化するために、次の kubernetes コマンドを使用して mongodb というラベルの付いた名前空間を作成することを検討してください。
kubectl create namespace mongodb
mongodb名前空間を使用しない場合は、名前空間に次のようにラベルを付けることができます。
kubectl create namespace <namespaceName>
任意:実行中のOps Managerを用意します。
Operator MongoDB Ops Managerを使用して リソースを配置しない場合は、 クラスターの外部でKubernetesMongoDB Ops Manager Kubernetesを実行する必要があります。Operator を使用して にMongoDB Ops Manager リソースを配置する場合は、この前提条件をスキップします。KubernetesKubernetes
重要
MongoDB Ops Managerインストールでは、アクティブなNTPサービスを実行する必要があります。 MongoDB Ops Managerホストのクロックが同期しない場合、そのホストはKubernetes Operator と通信できなくなります。
MongoDB Ops Managerホストの NTP サービスを確認する方法については、 RHEL のドキュメントを参照してください。
Considerations
次の計画トピックを確認します。詳細については、Kubernetes Operator のインストールの計画を参照してください。
単一の Kubernetes クラスターにインストールするか、複数の Kubernetes クラスターにインストールするかを決定します。参照: シングル クラスター またはマルチ クラスター インストール モードの選択。
Confirm that your versions of Kubernetes, OpenShift, MongoDB, and Ops Manager are compatible. See MongoDB Controllers for Kubernetes Operator Compatibility.
Kubernetes Operator 配置のスコープを設定します。これにより、 Kubernetes Operator が監視する名前空間が決定されます。Kubernetes Operator 配置用のMongoDBドライバーのスコープの設定 を参照してください。
ストレージ、永続性、CPU およびメモリの制限に関する本番環境の推奨事項を適用します。See ベストプラクティス.
Kubernetes を使用したインストール
インストール手順は、環境の構成方法によって異なります。
注意
全体で同じ名前空間を使用する
By default, the Kubernetes Operator deploys all resources in your Kubernetes cluster to the namespace mongodb. You can deploy Kubernetes Operator resources to a different namespace by editing all values for metadata.namespace in mongodb-kubernetes.yaml. You must also update the subjects[0].namespace value in every RoleBinding and ClusterRoleBinding in the same file. If you omit this value, the bindings look for the ServiceAccount in the default mongodb namespace and can't find it:
apiVersion: v1 kind: ServiceAccount metadata: name: mongodb-kubernetes-operator namespace: production apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: mongodb-kubernetes-operator namespace: production roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: mongodb-kubernetes-operator subjects: - kind: ServiceAccount name: mongodb-kubernetes-operator namespace: production apiVersion: apps/v1 kind: Deployment metadata: name: mongodb-kubernetes-operator namespace: production # Example truncated ...
任意: Kubernetes 演算子 YAML をインストールする前にカスタマイズします。
Kubernetes Operator のインストール設定の詳細については、「 Operator kubernetes および oc インストール設定 」を参照してください。
注意
静的コンテナのパブリック プレビューを有効にしてセキュリティを向上および簡素化するには、静的コンテナ(パブリック プレビュー)を参照してください。この機能は、パブリック プレビュー段階で本番環境で使用することは推奨しません。詳しくは、「 プレビュー機能 」を参照してください。
Kubernetes用のMongoDB Helm Charts を使用します。
Add the MongoDB Helm Charts for Kubernetes.
Kubernetes Operator Helm Chart は、次のコマンドを実行することでローカルに追加できます。
helm repo add mongodb https://mongodb.github.io/helm-charts
配置する前に Helm Chart をカスタマイズします。
任意の Kubernetes Operator インストール設定の詳細については、「 Operator Helm のインストール設定 」を参照してください。
Kubernetes 演算子 を配置します。
次のhelmコマンドを実行して、Kubernetes Operator を Kubernetes クラスター内のデフォルトの名前空間に配置します。
helm upgrade --install mongodb-kubernetes-operator mongodb/mongodb-kubernetes
次のように、 --namespaceと--create-namespaceフラグを渡して、Kubernetes Operator をデフォルト以外の名前空間に配置できます。
helm upgrade --install mongodb-kubernetes-operator mongodb/mongodb-kubernetes \ --namespace mongodb \ --create-namespace
Helm で特定の日次ビルドをインストール
MongoDB は毎日 Kubernetes Operator イメージを再ビルドして、最新のセキュリティと OS のアップデートを統合します。
デフォルトでは、 helmは指定したバージョンの Kubernetes Operator の最新ビルドをインストールします。
以前のビルドをインストールするには、 --set build=<build-id>を使用してパラメーターとしてビルド ID を指定します。 ビルド ID は常に-b<YYYYMMDD>T000000Zの形式で、 <YYYYMMDD>は使用するビルドが作成された日付です。
例
以下の例では、最新のイメージを使用して Kubernetes Operator をインストールする方法を示しています。
helm install mongodb-kubernetes-operator mongodb/mongodb-kubernetes
以下の例では、2021 年 2 月 5 日の午前 0 時に作成されたイメージで Kubernetes Operator をインストールする方法を示しています。
helm install mongodb-kubernetes-operator mongodb/mongodb-kubernetes \ --set build=-b20210205T000000Z
注意
MongoDB では、デフォルト(最新)のビルドを使用することを推奨しています。
OpenShift を使用したインストール
開始する前に、 Kubernetes Operator をOpenShiftに配置するときに、MANAGED_SECURITY_CONTEXT フラグが true に設定されていることを確認してください。この値は、values-openshift.YAMLファイルで事前定義されています。
インストール手順は、環境の構成方法によって異なります。
注意
全体で同じ名前空間を使用する
By default, the Kubernetes Operator deploys all resources in your Kubernetes cluster to the namespace mongodb. You can deploy Kubernetes Operator resources to a different namespace by editing all values for metadata.namespace in mongodb-kubernetes-openshift.yaml. You must also update the subjects[0].namespace value in every RoleBinding and ClusterRoleBinding in the same file. If you omit this value, the bindings look for the ServiceAccount in the default mongodb namespace and can't find it:
apiVersion: v1 kind: ServiceAccount metadata: name: mongodb-kubernetes-operator namespace: production apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: mongodb-kubernetes-operator namespace: production roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: mongodb-kubernetes-operator subjects: - kind: ServiceAccount name: mongodb-kubernetes-operator namespace: production apiVersion: apps/v1 kind: Deployment metadata: name: mongodb-kubernetes-operator namespace: production # Example truncated ...
Clone the MongoDB Controllers for Kubernetes Operator repository.
次のgitコマンドを呼び出します。
git clone https://github.com/mongodb/mongodb-kubernetes.git
Navigate to the directory in which you cloned the MongoDB Controllers for Kubernetes Operator repository.
たとえば、ホームページ ディレクトリのリポジトリをクローンした場合は、次を実行します。
cd ~/mongodb-kubernetes
Install the CustomResourceDefinitions for MongoDB deployments.
次の OC コマンドを呼び出します。
oc apply -f crds.yaml
任意: Kubernetes 演算子 YAML をインストールする前にカスタマイズします。
Kubernetes Operator のインストール設定の詳細については、「 Operator kubernetes および oc インストール設定 」を参照してください。
注意
静的コンテナのパブリック プレビューを有効にしてセキュリティを向上および簡素化するには、静的コンテナ(パブリック プレビュー)を参照してください。この機能は、パブリック プレビュー段階で本番環境で使用することは推奨しません。詳しくは、「 プレビュー機能 」を参照してください。
インストール前に、 Kubernetes 演算子 YAML で ServiceAccount 定義に <openshift-pull-secret> を追加してください。
apiVersion: v1 kind: ServiceAccount metadata: name: enterprise-operator namespace: mongodb imagePullSecrets: - name: <openshift-pull-secret> apiVersion: v1 kind: ServiceAccount metadata: name: mongodb-kubernetes-appdb namespace: mongodb imagePullSecrets: - name: <openshift-pull-secret> apiVersion: v1 kind: ServiceAccount metadata: name: mongodb-kubernetes-database-pods namespace: mongodb imagePullSecrets: - name: <openshift-pull-secret>
詳しくは、 Helm インストール設定のregistry.imagePullSecrets設定を参照してください。
Kubernetes用のMongoDB Helm Charts を使用します。
Helm3 を使用してKubernetes Operator をインストールできます。
Add the MongoDB Helm Charts for Kubernetes repository to Helm.
helm repo add mongodb https://mongodb.github.io/helm-charts
を使用してKubernetes Operatorhelm をインストールします。
Install MongoDB Helm Charts for Kubernetes:
helm install mongodb-kubernetes-operator mongodb/mongodb-kubernetes \ --values https://raw.githubusercontent.com/mongodb/helm-charts/main/charts/mongodb-kubernetes/values-openshift.yaml
値 -openshift.YAML を使用する 設定。任意の Kubernetes Operator インストール設定の詳細については、「 Operator Helm のインストール設定 」を参照してください。
注意
静的コンテナのパブリック プレビューを有効にしてセキュリティを向上および簡素化するには、静的コンテナ(パブリック プレビュー)を参照してください。この機能は、パブリック プレビュー段階で本番環境で使用することは推奨しません。詳しくは、「 プレビュー機能 」を参照してください。
Helm で特定の日次ビルドをインストール
MongoDB は毎日 Kubernetes Operator イメージを再ビルドして、最新のセキュリティと OS のアップデートを統合します。
デフォルトでは、 helmは指定したバージョンの Kubernetes Operator の最新ビルドをインストールします。
以前のビルドをインストールするには、 --set build=<build-id>を使用してパラメーターとしてビルド ID を指定します。 ビルド ID は常に-b<YYYYMMDD>T000000Zの形式で、 <YYYYMMDD>は使用するビルドが作成された日付です。
例
以下の例では、最新のイメージを使用して Kubernetes Operator をインストールする方法を示しています。
helm install mongodb-kubernetes-operator mongodb/mongodb-kubernetes
以下の例では、2021 年 2 月 5 日の午前 0 時に作成されたイメージで Kubernetes Operator をインストールする方法を示しています。
helm install mongodb-kubernetes-operator mongodb/mongodb-kubernetes \ --set build=-b20210205T000000Z
注意
MongoDB では、デフォルト(最新)のビルドを使用することを推奨しています。
インストールを確認します
Kubernetes Operator が正しくインストールされたことを確認するには、次のコマンドを実行し、出力を確認します。
kubectl describe deployments mongodb-kubernetes-operator -n <metadata.namespace>
oc describe deployments mongodb-kubernetes-operator -n <metadata.namespace>
デフォルトでは、配置はmongodb名前空間に存在します。 次のエラー メッセージが表示される場合は、正しい名前空間を使用していることを確認してください。
Error from server (NotFound): deployments.apps "mongodb-kubernetes-operator" not found
Kubernetes Operator のトラブルシューティングについては、「 Kubernetes Operator からのログの確認 」やその他のトラブルシューティング トピックを参照してください。
重要
Kubernetes Operator または名前空間を削除する必要がある場合は、まずMongoDB リソースを削除する必要があります。
次のステップ
Kubernetes Operator 用のMongoDBコントロール をインストールすると、次のことが可能になります。