本教程演示如何在受限网络OpenShift环境中使用Kubernetes Operator部署Kubernetes Operator、 MongoDB Ops Manager实例和MongoDB副本集。
步骤
镜像 Operator 目录并禁用默认目录。
Red Hat Operator 目录包含OLM查询以在集群上安装 Operator 及其依赖项的元数据。 您必须创建 Operator 目录的副本,然后以集群管理员身份禁用默认目录。
操作符包中的relatedImages列出了以下映像:
操作符直接使用的图像,即
mongodb-kubernetes-init-database、mongodb-kubernetes-init-ops-manager、mongodb-kubernetes-init-appdb、mongodb-kubernetes-init-database的当前版本。可以在MongoDB Ops Manager部署中配置的MongoDB Ops Manager 、AppDB 和
mongodb-agent-ubi当前支持的所有映像。
对于init映像,请仅使用最新 Kubernetes Operator 版本中存在的版本。
操作符包引用的所有相关映像的大小超过26 GB。
您的镜像命令不会选择不支持的 AppDB 映像版本。如果要使用任何其他不受支持的版本,则必须手动向镜像注册表提供这些映像。有关给定操作符版本的其他版本,请参阅部署映像。
RELATED_IMAGE_*有关 环境变量中定义的映像的完整列表,请参阅 CSV 文件。
要进行镜像,请参阅为离线安装制作镜像。
当您运行
oc adm catalog mirror命令来镜像目录时,会生成imageContentSourcePolicy.yaml文件,您必须应用该文件才能将原始源重新映射到镜像映像。示例:oc apply -f ./<output dir>/imageContentSourcePolicy.yaml 有关每个MongoDB Ops Manager版本支持的MongoDB版本列表,请参阅兼容的MongoDB版本。
要禁用默认目录,请将
disableAllDefaultSources: true添加到OperatorHub对象。
要学习;了解更多信息,请参阅在受限网络上使用 Operator Lifecycle 经理。
在本地模式下部署MongoDB Ops Manager 。
要在本地模式下部署MongoDB Ops Manager ,必须执行以下操作:
Copy the following example Ops Manager Kubernetes object and save it as a
.yamlfile.使用 中的 配置设置MongoDB Ops Manager
automation.versions.source: localspec.configuration来启用本地模式。Define a Persistent Volume for the Ops Manager StatefulSet to store the MongoDB installation archive. MongoDB Agent's running in MongoDB database resource containers that you create with the Kubernetes Operator download the installation archives from Ops Manager instead of from the Internet.
1 apiVersion: mongodb.com/v1 2 kind: MongoDBOpsManager 3 metadata: 4 name: ops-manager-localmode 5 spec: 6 replicas: 2 7 version: "8.0.0" 8 adminCredentials: ops-manager-admin-secret 9 configuration: 10 # this enables local mode in Ops Manager 11 automation.versions.source: local 12 statefulSet: 13 spec: 14 # the Persistent Volume Claim will be created for each Ops Manager Pod 15 volumeClaimTemplates: 16 - metadata: 17 name: mongodb-versions 18 spec: 19 accessModes: [ "ReadWriteOnce" ] 20 resources: 21 requests: 22 storage: "20Gi" 23 template: 24 spec: 25 containers: 26 - name: mongodb-ops-manager 27 volumeMounts: 28 - name: mongodb-versions 29 # this is the directory in each Pod where all MongoDB 30 # archives must be put 31 mountPath: /mongodb-ops-manager/mongodb-releases 32 backup: 33 enabled: false 34 applicationDatabase: 35 members: 3 36 persistent: true 要学习;了解有关设置的更多信息,请参阅部署MongoDB Ops Manager资源。
将
oc配置为默认命名空间。oc config set-context $(oc config current-context) --namespace=<metadata.namespace> 复制以下MongoDB Ops Manager资源设置,粘贴到现有MongoDB Ops Manager资源中,然后保存MongoDB Ops Manager配置文件。
1 configuration: 2 # this enables local mode in Ops Manager 3 automation.versions.source: local 4 statefulSet: 5 spec: 6 # the Persistent Volume Claim will be created for each Ops Manager Pod 7 volumeClaimTemplates: 8 - metadata: 9 name: mongodb-versions 10 spec: 11 accessModes: [ "ReadWriteOnce" ] 12 resources: 13 requests: 14 storage: "20Gi" 15 template: 16 spec: 17 containers: 18 - name: mongodb-ops-manager 19 volumeMounts: 20 - name: mongodb-versions 21 # this is the directory in each Pod where all MongoDB 22 # archives must be put 23 mountPath: /mongodb-ops-manager/mongodb-releases 将MongoDB安装存档复制到MongoDB Ops Manager持久卷。
要了解如何复制MongoDB安装存档,请参阅配置MongoDB Ops Manager资源以使用本地模式过程中的步骤 10。
创建凭证并将其存储为密钥。
运行以下命令:
注意
为以下参数提供公钥和私钥值。如需了解更多信息,请参阅“创建 Kubernetes Operator 的凭证”。
oc \ create secret generic ops-manager-admin-key \ --from-literal="publicKey=<publicKey>" \ --from-literal="privateKey=<privateKey>" 创建一个类似于以下内容的 ConfigMap:
cat <<EOF | oc apply -f - apiVersion: v1 kind: ConfigMap metadata: name: my-project namespace: mongodb data: projectName: myProjectName # this is an optional parameter orgId: 5b890e0feacf0b76ff3e7183 # this is a required parameter baseUrl: https://ops.example.com:8443 EOF 要了解有关 ConfigMap 中设置的更多信息,请参阅OpenShift 快速入门中的步骤7 。
要学习;了解有关在本地模式下部署MongoDB Ops Manager的更多信息,请参阅配置MongoDB Ops Manager资源以使用本地模式。
部署MongoDB database资源。
您可以部署副本集或部署分片集群。 要了解更多信息,请参阅部署MongoDB database资源。