本教程演示如何在受限网络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当前支持的所有映像。
对于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 ,必须执行以下操作:
复制以下示例MongoDB Ops Manager Kubernetes 对象 并将其保存为
.yaml文件。使用 中的 配置设置MongoDB Ops Manager
automation.versions.source: localspec.configuration来启用本地模式。
apiVersion: mongodb.com/v1kind: MongoDBOpsManagermetadata: name: ops-manager-localmodespec: replicas: 2 version: "8.0.0" adminCredentials: ops-manager-admin-secret configuration: # this enables local mode in Ops Manager automation.versions.source: local statefulSet: spec: # the Persistent Volume Claim will be created for each Ops Manager Pod volumeClaimTemplates: - metadata: name: mongodb-versions spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: "20Gi" template: spec: containers: - name: mongodb-ops-manager volumeMounts: - name: mongodb-versions # this is the directory in each Pod where all MongoDB # archives must be put mountPath: /mongodb-ops-manager/mongodb-releases backup: enabled: false applicationDatabase: members: 3 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配置文件。
configuration: # this enables local mode in Ops Manager automation.versions.source: localstatefulSet: spec: # the Persistent Volume Claim will be created for each Ops Manager Pod volumeClaimTemplates: - metadata: name: mongodb-versions spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: "20Gi" template: spec: containers: - name: mongodb-ops-manager volumeMounts: - name: mongodb-versions # this is the directory in each Pod where all MongoDB # archives must be put 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: v1kind: ConfigMapmetadata: name: my-project namespace: mongodbdata: projectName: myProjectName # this is an optional parameter orgId: 5b890e0feacf0b76ff3e7183 # this is a required parameter baseUrl: https://ops.example.com:8443EOF要了解有关 ConfigMap 中设置的更多信息,请参阅OpenShift 快速入门中的步骤7 。
要学习;了解有关在本地模式下部署MongoDB Ops Manager的更多信息,请参阅配置MongoDB Ops Manager资源以使用本地模式。
部署MongoDB database资源。
您可以部署副本集或部署分片集群。 要了解更多信息,请参阅部署MongoDB database资源。