MongoDBMultiCluster资源定义您的多 Kubernetes集群MongoDB 部署,并为Kubernetes Operator 的MongoDB控制器提供创建或更新集群、 MongoDB Ops Manager部署、 statefulSets 、服务和其他Kubernetes资源所需的信息。
例子
以下示例显示了多 Kubernetes 集群 MongoDB 部署的资源规范:
1 # This example provides statefulSet overrides per cluster. 2 3 apiVersion: mongodb.com/v1 4 kind: MongoDBMultiCluster 5 metadata: 6 name: multi-replica-set 7 spec: 8 version: 8.0.0 9 type: ReplicaSet 10 duplicateServiceObjects: false 11 credentials: my-credentials 12 opsManager: 13 configMapRef: 14 name: my-project 15 clusterSpecList: 16 - clusterName: cluster1.example.com 17 members: 2 18 statefulSet: 19 spec: 20 template: 21 spec: 22 containers: 23 # Example of custom sidecar containers. Remove it before using the file in production. 24 - name: sidecar1 25 image: busybox 26 command: [ "sleep" ] 27 args: [ "infinity" ] 28 # Use the following settings to override the default storage size of the "data" Persistent Volume. 29 volumeClaimTemplates: 30 - metadata: 31 name: data 32 spec: 33 resources: 34 requests: 35 storage: 1Gi 36 - clusterName: cluster2.example.com 37 members: 1 38 statefulSet: 39 spec: 40 template: 41 spec: 42 containers: 43 # Example of custom sidecar containers. Remove it before using the file in production. 44 - name: sidecar2 45 image: busybox 46 command: [ "sleep" ] 47 args: [ "infinity" ] 48 volumeClaimTemplates: 49 - metadata: 50 name: data 51 spec: 52 resources: 53 requests: 54 storage: 1Gi 55 - clusterName: cluster3.example.com 56 members: 1 57 statefulSet: 58 spec: 59 template: 60 spec: 61 containers: 62 # Example of custom sidecar containers. Remove it before using the file in production. 63 - name: sidecar3 64 image: busybox 65 command: [ "sleep" ] 66 args: [ "infinity" ] 67 volumeClaimTemplates: 68 - metadata: 69 name: data 70 spec: 71 resources: 72 requests: 73 storage: 1Gi 74 75 ...
所需的MongoDBMultiCluster 资源设置
本部分介绍必须用于MongoDBMultiCluster资源的设置。
apiVersion类型:字符串
MongoDB Kubernetes 资源模式的版本。
kind类型:字符串
要创建的 MongoDB Kubernetes 资源类型。 将其设置为
MongoDBMultiCluster。
metadata.name类型:字符串
您正在创建的 MongoDB Kubernetes 资源的名称。
资源名称必须少于或等于 44 个字符。
spec.credentials类型:字符串
您创建的 Secret 名称,其将作为 Ops Manager API 身份验证凭证,以便 Kubernetes Operator 与 Ops Manager 进行通信。
The Ops Manager Kubernetes Secret object holding the Credentials must exist on the same Namespace as the resource you want to create.
重要
Operator 管理对密钥的更改
Kubernetes Operator 会跟踪该 Secret 的任何更改并协调
MongoDB资源的状态。
spec.type类型:字符串
要创建的 MongoDB Kubernetes 资源的类型。 多 Kubernetes 集群 MongoDB 部署的唯一可接受值是ReplicaSet 。
spec.version类型:字符串
为此
MongoDBMultiCluster资源安装的 MongoDB 版本。
可选的MongoDBMultiCluster 资源设置
MongoDBMultiCluster 资源可以使用以下设置:
spec.additionalMongodConfig类型:集合
启动 MongoDB 进程时需要使用的其他配置选项。
Kubernetes Operator 支持您通过 MongoDB 助手部署的 MongoDB 版本所支持的所有配置选项,但 Kubernetes Operator 会覆盖您为以下任何选项提供的值:
net.portnet.tls.certificateKeyFilenet.tls.clusterFilereplication.replSetNamesecurity.clusterAuthModesharding.clusterRolestorage.dbPathsystemLog.destinationsystemLog.path
要详细了解 Kubernetes Operator 拥有的配置选项,请参阅 MongoDB Kubernetes Operator 独有设置。
To learn which configuration options you can use, see Advanced Options for MongoDB Deployments in the Ops Manager documentation.
spec.agent类型:集合
MongoDB 数据库资源的 MongoDB 助手配置设置。
spec.agent.startupOptions类型:集合
要用于启动 MongoDB database 资源的 MongoDB Agent 设置。
您必须以键值对形式提供 MongoDB 助手设置。这些值必须是字符串。 有关支持的 MongoDB 助手设置列表,请参阅:
云管理器项目的 MongoDB 代理设置。
使用 Kubernetes Operator 部署的 Ops Manager 版本的 MongoDB 助手设置。
spec.backup类型:集合
The collection container for spec.backup.mode, which enables continuous backups for MongoDB resources in Kubernetes Operator.
spec.backup.assignmentLabels类型:数组
备份守护程序服务进程的分配标签列表。 使用分配标签来标识与特定项目相关联的特定备份守护进程。 如果使用Kubernetes Operator 设置分配标签,则在Kubernetes配置文件中为分配标签设置的值将覆盖MongoDB Ops Manager用户界面中定义的值。 未使用Kubernetes Operator 设置的分配标签将继续使用MongoDB Ops Manager用户界面中设置的值。
spec.backup.autoTerminateOnDeletion类型:布尔值
Flag that indicates whether the Kubernetes Operator stops and terminates the backup when you delete a
MongoDBMultiClusterresource. The default value isfalse. Setting this flag totrueis useful when you want to delete theMongoDBMultiClusterresource while the spec.backup.mode setting is set toenabled.
spec.backup.encryption类型:对象
包含备份加密配置设置的对象。
spec.backup.encryption.kmip类型:对象
Object that contains the KMIP backup encryption configuration settings. To learn more, see Configure KMIP Backup Encryption for Ops Manager.
spec.backup.encryption.kmip.client类型:对象
包含 KMIP 备份加密客户端配置设置的对象。
spec.backup.mode类型:字符串
为
MongoDBMultiCluster资源启用连续备份。 可能的值为enabled、disabled和terminated。注意
The spec.backup.mode setting relies on Backup that is enabled in Ops Manager and requires that the
spec.backup.enabledvalue in the Ops Manager resource specification is set totrue.After you enable continuous backups for your MongoDB resource with spec.backup.mode, you can check the backup status.
spec.backup.snapshotSchedule类型:集合
用于 Kubernetes Operator 中的 MongoDB 资源连续备份的快照计划设置的集合容器。
spec.backup.snapshotSchedule.dailySnapshotRetentionDays类型:数字
保留每日快照的天数。 您可以设置介于
1和365(含)之间的值。 将值设置为0将禁用此规则。
spec.backup.snapshotSchedule.fullIncrementalDayOfWeek类型:字符串
Ops Manager 撷取完整快照的星期几。此设置可确保最近的完整备份。Ops Manager 会将默认值设置为
SUNDAY。
spec.backup.snapshotSchedule.monthlySnapshotRetentionMonths类型:数字
保留每月快照的月数。可以设置介于
1和36(含 36)之间的值。将该值设置为0将禁用此规则。
spec.backup.snapshotSchedule.pointInTimeWindowHours类型:数字
可以创建时间点快照的过去小时数。
spec.backup.snapshotSchedule.referenceHourOfDay类型:数字
一天中的 UTC 小时,用于使用 24 小时制安排快照。可以设置介于
0和23(包含)之间的值。
spec.backup.snapshotSchedule.referenceMinuteOfHour类型:数字
小时的 UTC 分钟,用于安排快照。您可以设置介于
0和59(含)之间的值。
spec.backup.snapshotSchedule.snapshotIntervalHours类型:数字
快照之间的小时数。可以设置的值包括
6、8、12或24。
spec.backup.snapshotSchedule.snapshotRetentionDays类型:数字
保留最近快照的天数。可以设置介于
2和5(含 36)之间的值。
spec.backup.snapshotSchedule.weeklySnapshotRetentionWeeks类型:数字
保存每周快照的周数。可以设置介于
1和52(含 36)之间的值。将该值设置为0将禁用此规则。
spec.cloudManager.configMapRef.name类型:字符串
Alias for spec.opsManager.configMapRef.name.
spec.clusterSpecList类型:集合
MongoDBMultiCluster资源中每个 Kubernetes 集群的规范列表。
spec.clusterSpecList.clusterName类型:字符串
MongoDB Controllers for Kubernetes 操作符 在其中安排 StatefulSet 的集群的名称。当 Kubernetes 操作符 部署此
MongoDBMultiCluster资源时,它会创建一个服务帐户。此名称是中央集群中的服务帐户用于与工作负载集群通信的名称。
spec.clusterSpecList.externalAccess.externalDomain类型:字符串
用于向外部公开您的副本集部署的外部域。
默认情况下,每个副本集节点使用 Kubernetes Pod 的FQDN (
*.svc.cluster.local) 作为默认主机名。不过,如果您将一个外部域添加到该设置中,副本集将使用作为指定域的子域的主机名。此主机名使用以下格式:<replica-set-name>-<cluster-idx>-<pod-idx>.<externalDomain>例如:
multi-replica-set-0-1.cluster-0.example.comAfter you deploy the replica set with this setting, the Kubernetes Operator uses the hostname with the external domain to override the
processes[n].hostnamefield in the Ops Manager automation configuration. Then, the MongoDB Agent uses this hostname to connect tomongod.要指定用于连接到副本集的其他主机名,可以使用
spec.connectivity.replicaSetHorizons设置。但是,以下连接仍会使用包含外部域的主机名:The MongoDB Agent to connect to
mongod.
WARNING: Specifying this field changes how Ops Manager registers
mongodprocesses. You can't change the value of this field or anyprocesses[n].hostnamefields in the Ops Manager automation configuration for a running replica set deployment.重要
仅当在没有服务网格的情况下部署多 Kubernetes 集群 MongoDB 部署副本集时,才使用此设置。 请参阅在没有服务网格的多 Kubernetes 集群中部署副本集。
spec.clusterSpecList.externalAccess.externalService类型:集合
Configuration for externally exposing a specific cluster in your multi-Kubernetes cluster MongoDB deployment. These settings override the global spec.externalAccess.externalService settings.
当您设立spec.externalAccess 设置时, Kubernetes Operator 会自动使用默认值创建外部负载负载均衡器服务。您可以根据需要覆盖某些值或添加新值。示例,如果您打算创建 NodePort 服务并且不需要负载负载均衡器,则必须在Kubernetes规范中配置覆盖:
externalAccess: externalService: annotations: # cloud-specific annotations for the service spec: type: NodePort # default is LoadBalancer # you can specify other spec overrides if necessary 有关 Kubernetes 规范的更多信息,请参阅 Kubernetes 文档中的 ServiceSpec。
spec.clusterSpecList.externalAccess.externalService.annotations类型:集合
键值对,可让您将特定云提供商的配置设置添加到多 Kubernetes集群MongoDB 部署中的特定集群。此设置会覆盖全局设置 spec.externalAccess.externalService.annotations。要学习;了解更多信息,请参阅Kubernetes云提供商的注释和文档。
您可以使用注解为Kubernetes Operator 部署使用的外部服务指定占位符值。Kubernetes Operator 会自动将这些值替换为正确的值,如下表所述。使用占位符,您可以在每个服务中为特定 Pod 提供特定注释。
值说明{resourceName}{namespace}{podIndex}StatefulSet 分配且当前外部服务所针对的 Pod 的索引。
{podName}等于
{resourceName}-{clusterIndex}-{podIndex}。{clusterName}The current cluster name set in spec.clusterSpecList.clusterName.
{clusterIndex}The index initially assigned by the Kubernetes Operator for the current cluster name set in spec.clusterSpecList.clusterName.
This value might not reflect the order of the member clusters defined in spec.clusterSpecList. Although you can change the order of member clusters in spec.clusterSpecList, the Kubernetes Operator still uses the index that it initially assigned for the current cluster name.
{statefulSetName}StatefulSet。等于
{resourceName}-{clusterIndex}。{externalServiceName}根据指定的占位符值生成的外部服务名称。 等于
{resourceName}-{clusterIndex}-{podIndex}-svc-external。{mongodProcessDomain}The domain name of the server that is hosting the mongod process. Equal to spec.externalAccess.externalDomain if specified. Otherwise, equal to the domain used for the
mongodprocess FQDN.例如,对于进程主机名
mdb-rs-1.example.com,example.com是域名。{mongodProcessFQDN}The
mongodprocess hostname set in the automation configuration.The process hostname depends on your deployment configuration. If you've configured your multi-Kubernetes cluster MongoDB deployment to use external domains, such as for a deployment without service mesh, the process hostname uses the following format:
{resourceName}-{clusterIndex}-{podIndex}.{mongodProcessDomain}例如:
mdb-rs-0-1.example.com如果您的部署不使用外部域,则进程主机名将使用以下格式:
{resourceName}-{clusterIndex}-{podIndex}-svc.{namespace}.svc.cluster.local例如:
mdb-rs-1-svc.ns.svc.cluster.local注意
您必须仅使用表中指定的已知占位符值,并确保占位符不使用空值或 null 值。 否则,Kubernetes Operator 将返回错误。 例如,您可能会遇到以下错误消息:
error replacing placeholders in map with key=external-dns.alpha.kubernetes.io/hostname, value={resourceName}-{podIndex}-{unknownPlaceholder}.{clusterName}-{clusterIndex}.example.com: missing values for the following placeholders: {clusterName}, {clusterIndex}, {unknownPlaceholder}`` 例子
以下示例指定了
{resourceName}、{podIndex}和{namespace}占位符:apiVersion: mongodb.com/v1 kind: MongoDB metadata: name: mdb-rs namespace: ns spec: replicas: 3 externalAccess: externalService: annotations: external-dns.alpha.kubernetes.io/hostname: {resourceName}-{podIndex}-{namespace}.example.com Kubernetes Operator 会根据每个占位符的正确值自动填充外部服务的注释。 例如:
mdb-rs-0-svc-external: annotations: external-dns.alpha.kubernetes.io/hostname: mdb-rs-0-ns.example.com mdb-rs-1-svc-external: annotations: external-dns.alpha.kubernetes.io/hostname: mdb-rs-1-ns.example.com mdb-rs-2-svc-external: annotations: external-dns.alpha.kubernetes.io/hostname: mdb-rs-2-ns.example.com
spec.clusterSpecList.externalAccess.externalService.spec类型:集合
ServiceSpec 的配置 。要了解更多信息,请参阅spec.clusterSpecList.externalAccess.externalService。
spec.clusterSpecList.memberConfig类型:集合
多 Kubernetes 集群 MongoDB 部署中每个 MongoDB 副本集及其成员的规范。
每个副本集的对象中元素的顺序必须反映副本集中成员的顺序。 例如,第一个元素影响索引为
0的 Pod,第二个元素影响索引为1的 Pod,依此类推。例子
请考虑以下具有三个副本集的多 Kubernetes 集群 MongoDB 部署的示例规范:
apiVersion: mongodb.com/v1 kind: MongoDBMultiCluster metadata: name: multi-replica-set spec: version: 8.0.0 type: ReplicaSet duplicateServiceObjects: false credentials: my-credentials opsManager: configMapRef: name: my-project clusterSpecList: - clusterName: cluster1.example.com members: 2 memberConfig: - votes: 1 priority: "0.5" tags: tag1: "value1" environment: "prod" - votes: 1 priority: "1.5" tags: tag2: "value2" environment: "prod" - clusterName: cluster2.example.com members: 1 memberConfig: - votes: 1 priority: "0.5" tags: tag1: "value1" environment: "prod" - clusterName: cluster3.example.com members: 1 memberConfig: - votes: 1 priority: "0.5" tags: tag1: "value1" environment: "prod"
spec.clusterSpecList.memberConfig.priority类型:字符串
Number that indicates the relative likelihood of a MongoDB replica set member to become the primary.
要增加副本集节点成为主节点的相对可能性,请指定较高的
priority值。要降低副本集节点成为主节点的相对可能性,请指定较低的
priority值。
例如,
memberConfig.priority为1.5的成员比memberConfig.priority为0.5的成员更有可能成为主节点。A member with a
memberConfig.priorityof0is ineligible to become the primary. To learn more, see Member Priority.
spec.clusterSpecList.memberConfig.tags类型:地图
副本集标签映射,用于将读取和写入操作定向到您的 MongoDB 副本集的特定节点。
spec.clusterSpecList.memberConfig.votes类型:数字
确定 MongoDB 副本集成员能否在选举中投票。设置为
1将允许成员投票。设置为0会将成员排除在选举之外。
spec.clusterSpecList.members类型:数字
MongoDB 副本集中的节点数。
spec.clusterSpecList.service类型:字符串
默认值:<resource_name>+"-service"
要创建或用于StatefulSet的Kubernetes服务的名称。如果具有此名称的服务已存在, MongoDB Controllers for Kubernetes Operator 不会删除或重新创建该服务。通过此设置,您可以创建自己的自定义服务,并允许Kubernetes Operator 重复使用这些服务。
spec.clusterSpecList.statefulSet.spec类型:集合
为多 Kubernetes集群MongoDB 部署中集群的每个 StatefulSet 提供 StatefulSet 覆盖的配置。要设立适用于多 Kubernetes集群MongoDB 部署中所有集群的全局配置,请参阅 spec.statefulSet.spec.
此设置仅适用于多 Kubernetes 集群 MongoDB 部署中的副本集资源类型。
spec.connectivity.replicaSetHorizons类型:集合
允许您为客户端应用程序和 MongoDB 助手提供不同的 DNS 设置。Kubernetes Operator 为副本集节点使用水平分割 DNS。此功能允许 Kubernetes 集群内部与 Kubernetes 外部进行通信。
您可以为每个主机添加多个外部映射。
注意
确保该数组中的每个值是唯一的。
确保此数组中的条目数与 spec.clusterSpecList.members. 中给定的值匹配。
Provide a value for the spec.security.certsSecretPrefix setting to enable TLS. This method to use split horizons requires the Server Name Indication extension of the TLS protocol.
在此示例中,客户端使用
example-website配置与副本集进行通信。15 security: 16 tls: 17 enabled: true 18 connectivity: 19 replicaSetHorizons: 20 - "example-website": "web1.example.com:30907" 21 - "example-website": "web2.example.com:32350" 22 - "example-website": "web3.example.com:31185" 23 ...
spec.duplicateServiceObjects类型:布尔值
默认值:true
指定Kubernetes Operator 是否在每个集群中复制 Pod 的服务网格对象以允许DNS解析。 如果您为服务网格配置 DNS 代理,则设置为
false。 示例,请参阅 DNS 代理 在 Istio 文档中。
spec.externalAccess类型:集合
用于向外部连接公开多 Kubernetes集群MongoDB 部署的规范。 要学习;了解如何从 Kubernetes集群外部连接到多 Kubernetes集群MongoDB 部署,请参阅从外部KubernetesKubernetes到多集群资源。
这些设置应用于所有集群中的服务。要在特定集群中覆盖这些全局设置,请使用 spec.clusterSpecList.externalAccess.externalService.
如果您添加
spec.externalAccess,则 Kubernetes Operator 为副本集中的每个 Pod 创建一个外部服务。外部服务为集群中的每个 MongoDB 数据库 Pod 提供外部入口点。每个外部服务具有选择器,它将外部服务与特定 Pod 相匹配。如果添加此设置时不带任何值,Kubernetes Operator 会创建具有以下默认值的外部服务:
字段值说明Name<pod-name>-svc-external外部服务的名称。您无法更改此值。
TypeLoadBalancer创建外部 LoadBalancer 服务。
Port<Port Number>A port for
mongod.publishNotReadyAddresstrue指定即使 Pod 尚未准备就绪,也会创建 DNS 记录。对于任何数据库Pod,请勿设立为
false。注意
If you set spec.clusterSpecList.externalAccess.externalDomain, the external service adds another port (
Port Number + 1) for backups.
spec.externalAccess.externalService类型:集合
当您设立spec.externalAccess 设置时, Kubernetes Operator 会自动使用默认值创建外部负载负载均衡器服务。您可以根据需要覆盖某些值或添加新值。示例,如果您打算创建 NodePort 服务并且不需要负载负载均衡器,则必须在Kubernetes规范中配置覆盖:
externalAccess: externalService: annotations: # cloud-specific annotations for the service spec: type: NodePort # default is LoadBalancer # you can specify other spec overrides if necessary 有关 Kubernetes 规范的更多信息,请参阅 Kubernetes 文档中的 ServiceSpec。
spec.externalAccess.externalService.annotations类型:集合
键值对,可让您将特定云提供商的配置设置添加到多 Kubernetes集群MongoDB 部署中的所有集群。有关特定于集群的覆盖项,请参阅 spec.clusterSpecList.externalAccess.externalService.annotations。要学习;了解更多信息,请参阅用于Kubernetes部署的云提供商的注释和文档。
您可以使用注解为Kubernetes Operator 部署使用的外部服务指定占位符值。Kubernetes Operator 会自动将这些值替换为正确的值,如下表所述。使用占位符,您可以在每个服务中为特定 Pod 提供特定注释。
值说明{resourceName}{namespace}{podIndex}StatefulSet 分配且当前外部服务所针对的 Pod 的索引。
{podName}等于
{resourceName}-{clusterIndex}-{podIndex}。{clusterName}The current cluster name set in spec.clusterSpecList.clusterName.
{clusterIndex}The index initially assigned by the Kubernetes Operator for the current cluster name set in spec.clusterSpecList.clusterName.
This value might not reflect the order of the member clusters defined in spec.clusterSpecList. Although you can change the order of member clusters in spec.clusterSpecList, the Kubernetes Operator still uses the index that it initially assigned for the current cluster name.
{statefulSetName}StatefulSet。等于
{resourceName}-{clusterIndex}。{externalServiceName}根据指定的占位符值生成的外部服务名称。 等于
{resourceName}-{clusterIndex}-{podIndex}-svc-external。{mongodProcessDomain}The domain name of the server that is hosting the mongod process. Equal to spec.externalAccess.externalDomain if specified. Otherwise, equal to the domain used for the
mongodprocess FQDN.例如,对于进程主机名
mdb-rs-1.example.com,example.com是域名。{mongodProcessFQDN}The
mongodprocess hostname set in the automation configuration.The process hostname depends on your deployment configuration. If you've configured your multi-Kubernetes cluster MongoDB deployment to use external domains, such as for a deployment without service mesh, the process hostname uses the following format:
{resourceName}-{clusterIndex}-{podIndex}.{mongodProcessDomain}例如:
mdb-rs-0-1.example.com如果您的部署不使用外部域,则进程主机名将使用以下格式:
{resourceName}-{clusterIndex}-{podIndex}-svc.{namespace}.svc.cluster.local例如:
mdb-rs-1-svc.ns.svc.cluster.local注意
您必须仅使用表中指定的已知占位符值,并确保占位符不使用空值或 null 值。 否则,Kubernetes Operator 将返回错误。 例如,您可能会遇到以下错误消息:
error replacing placeholders in map with key=external-dns.alpha.kubernetes.io/hostname, value={resourceName}-{podIndex}-{unknownPlaceholder}.{clusterName}-{clusterIndex}.example.com: missing values for the following placeholders: {clusterName}, {clusterIndex}, {unknownPlaceholder}`` 例子
以下示例指定了
{resourceName}、{podIndex}和{namespace}占位符:apiVersion: mongodb.com/v1 kind: MongoDB metadata: name: mdb-rs namespace: ns spec: replicas: 3 externalAccess: externalService: annotations: external-dns.alpha.kubernetes.io/hostname: {resourceName}-{podIndex}-{namespace}.example.com Kubernetes Operator 会根据每个占位符的正确值自动填充外部服务的注释。 例如:
mdb-rs-0-svc-external: annotations: external-dns.alpha.kubernetes.io/hostname: mdb-rs-0-ns.example.com mdb-rs-1-svc-external: annotations: external-dns.alpha.kubernetes.io/hostname: mdb-rs-1-ns.example.com mdb-rs-2-svc-external: annotations: external-dns.alpha.kubernetes.io/hostname: mdb-rs-2-ns.example.com
spec.externalAccess.externalService.spec类型:集合
ServiceSpec 的配置。要学习;了解更多信息,请参阅 spec.externalAccess.externalService.
spec.featureCompatibilityVersion类型:数字
Limits changes to data that occur with an upgrade to a new major version. This allows you to downgrade to the previous major version. To learn more about feature compatibility, see
setFeatureCompatibilityVersionin the MongoDB Manual.
spec.logLevel类型:字符串
配置 Pod 内自动化代理日志记录的级别。接受的值包括:
DEBUGINFOWARNERRORFATAL
spec.opsManager.configMapRef.name类型:字符串
ConfigMap 的名称 使用Cloud Manager 或MongoDB Ops Manager 连接配置。spec.cloudManager.configMapRef.name设置是此设置的别名,可以用来代替它。
此值必须与待创建的资源位于同一命名空间。
重要
Operator 管理对 ConfigMap 的更改
Kubernetes Operator 会跟踪该 ConfigMap 的任何更改并协调
MongoDB资源的状态。
spec.persistent类型:布尔值
默认值:true
警告:授予容器写入持久卷的权限。 Kubernetes Operator 在
securityContext中设置fsGroup = 2000、runAsUser = 2000和runAsNonRoot = true。 Kubernetes Operator 将fsgroup设置为等于runAsUser,以使在容器中运行主进程的用户可写入该卷。要学习;了解更多信息,请参阅Kubernetes文档中的为 Pod 或容器配置安全上下文以及相关讨论。如果重新部署资源无法解决持久卷的问题,联系MongoDB支持部门。如果您不使用持久卷,则在查看此部署的数据时,Disk Usage 和 Disk IOPS 图表将无法显示在 Deployment 页面上的 Processes标签页中,也无法显示在 Metrics 页面中。
spec.security.authentication类型:集合
多 Kubernetes集群MongoDB 部署的身份验证规范。
spec.security.authentication.agents类型:集合
Cloud Manager 或 Ops Manager 项目的 MongoDB 助手身份验证配置。
spec.security.authentication.agents.automationLdapGroupDN类型:字符串
MongoDB 助手用户所属的 LDAP 组的可分辨名称 (DN)。
在以下情况下需要使用此设置:
spec.security.authentication.agents.mode is
LDAPorX509.
spec.security.authentication.agents.automationPasswordSecretRef类型:集合
密钥 的详细信息 包含 spec.security.authentication.agents.automationUserName 的密码用户。
This setting is required if spec.security.authentication.agents.mode is
LDAP.
spec.security.authentication.agents.automationPasswordSecretRef.key类型:字符串
键入 spec.security.authentication.agents.automationPasswordSecretRef.name 密钥 包含 spec.security.authentication.agents.automationUserName 中用户的密码。
This setting is required if spec.security.authentication.agents.mode is
LDAP.
spec.security.authentication.agents.automationPasswordSecretRef.name类型:字符串
密钥 名称 包含 spec.security.authentication.agents.automationUserName 的密码用户。 您必须在部署 Kubernetes Operator 的同一命名空间中创建此密钥:
kubectl create secret generic ldap-agent-user \ --from-literal="password=<password>" -n <metadata.namespace> 此密钥必须包含一个密钥,其值与spec.security.authentication.agents.automationUserName LDAP 。
This setting is required if spec.security.authentication.agents.mode is
LDAP.
spec.security.authentication.agents.automationPasswordSecretRef.optional类型:布尔值
指定这些选项是必需还是可选的:
spec.security.authentication.agents.automationUserName类型:字符串
Name of the user that the MongoDB Agents use to interact with your multi-Kubernetes cluster MongoDB deployment. The username is mapped to an LDAP Distinguished Name (DN) according to spec.security.authentication.ldap.userToDNMapping. The resulting DN must already exist in your LDAP deployment.
This setting is required if spec.security.authentication.agents.mode is
LDAP.
spec.security.authentication.agents.clientCertificateSecretRef.name类型:字符串
默认:代理-certs
此密钥必须包含
mms-automation-agent-pem密钥。此密钥的值必须是可由服务器验证的 TLS 证书。必须在部署 Kubernetes Operator 的同一命名空间中创建此密钥:
kubectl create secret generic agent-certs \ --from-file=mms-automation-agent-pem=<automation-cert.pem> \ --namespace=<metadata.namespace>
spec.security.authentication.enabled类型:布尔值
默认:false
指定是否在Cloud Manager或MongoDB Ops Manager项目上启用身份验证。 如果设置为
true,则必须在spec.security.authentication.modes 中设置身份验证机制。重要
如果包含此设置,即使将其设置为
false,Kubernetes 操作符也会托管此 MongoDB 资源的身份验证。当资源规范中存在此设置时,您无法使用 Cloud Manager 或 Ops Manager 用户界面或 API 配置此资源的身份验证。如果要使用 Cloud Manager 或 Ops Manager 用户界面或 API 托管身份验证,请忽略此设置。
spec.security.authentication.agents.mode类型:字符串
The authentication mechanism that the MongoDB Agents for your multi-Kubernetes cluster MongoDB deployment use. Valid values are
SCRAM,SCRAM-SHA-1,MONGODB-CR,X509, andLDAP. The value you specify must also be present in spec.security.authentication.modes. We recommendSCRAM-SHA-256 (SCRAM)overSCRAM-SHA-1. If you specifySCRAM-SHA-1, you must also specifyMONGODB-CR.This setting is required if you specified more than one value for spec.security.authentication.modes.
spec.security.authentication.ignoreUnknownUsers类型:布尔值
默认:false
确定是否可以修改未通过 Kubernetes Operator、Cloud Manager 或 Ops Manager 用户界面配置的数据库用户。
To manage database users directly through the
mongodormongos, set totrue.
spec.security.authentication.internalCluster类型:字符串
Specifies whether X.509 internal cluster authentication is enabled.
要启用 X.509 内部集群身份验证,请设置为
"X509"。要求指定以下设置:spec.security.authentication.modes
: ["X509"]
Kubernetes Operator 接受以下值:
["X509"]:启用 X.509 内部集群身份验证。""或省略:未启用内部集群身份验证。
重要
启用内部集群身份验证后,就无法再将其禁用。
spec.security.authentication.ldap类型:集合
LDAP 身份验证所需。
Configures LDAP authentication for the Cloud Manager or Ops Manager project. To enable LDAP authentication, set spec.security.authentication.modes to
["LDAP"].
spec.security.authentication.ldap.authzQueryTemplate类型:字符串
是 LDAP 授权所必需的。
由MongoDB执行的 RFC4515 和 RFC4516 LDAP格式查询URL模板,用于获取用户所属的LDAP群组。该查询相对于
spec.security.authentication.ldap.servers中指定的托管或多个主机。您可以在模板中使用以下词元:{USER}- Substitutes the authenticated username, or the
transformedusername, into the LDAP query.
{PROVIDED_USER}- 在身份验证或 LDAP 转换之前,将提供的用户名替换到 LDAP 查询中。 (从 MongoDB 版本 4.2 开始可用)。
有关详细信息,请参阅 MongoDB 手册中的LDAP 查询模板。
spec.security.authentication.ldap.bindQueryPasswordSecretRef类型:集合
LDAP 身份验证所需。
指定密钥,其中包含 MongoDB 在连接到LDAP 服务器时绑定的密码。
spec.security.authentication.ldap.bindQueryPasswordSecretRef.name类型:字符串
LDAP 身份验证所需。
密钥的名称,该密钥包含了 MongoDB 在连接到 LDAP 服务器时绑定的密码。
密钥 必须仅包含一个用于存储密码的
password字段。
spec.security.authentication.ldap.bindQueryUser类型:字符串
LDAP 身份验证所需。
连接到 LDAP 服务器时 MongoDB 绑定到的 LDAP 可分辨名称。
spec.security.authentication.ldap.caConfigMapRef类型:集合
是使用 TLS 进行 LDAP 身份验证所必需的。
ConfigMap,其中包含验证 LDAP 服务器的 TLS 证书的 CA。
spec.security.authentication.ldap.caConfigMapRef.key类型:字符串
是使用 TLS 进行 LDAP 身份验证所必需的。
存储验证 LDAP 服务器 TLS 证书的 CA 的字段名称。
spec.security.authentication.ldap.caConfigMapRef.name类型:字符串
是使用 TLS 进行 LDAP 身份验证所必需的。
ConfigMap 的名称,它包含验证 LDAP 服务器的 TLS 证书的 CA。
spec.security.authentication.ldap.caConfigMapRef.optional类型:布尔值
指定这些选项是必需还是可选的:
spec.security.authentication.ldap.servers类型:字符串数组
LDAP 身份验证所需。
List of hostnames and ports of the LDAP servers. Specify hostnames with their respective ports in the following format:
spec: security: authentication: ldap: servers: - "<hostname1>:<port1>" - "<hostname2>:<port2>"
spec.security.authentication.ldap.timeoutMS类型:整型
指定身份验证请求超时前应等待的毫秒数。
spec.security.authentication.ldap.transportSecurity类型:字符串
LDAP 身份验证所需。
指定 LDAP 服务器是否接受 TLS。
如果 LDAP 服务器接受 TLS,请将该值设为
tls。如果 LDAP 服务器不接受 TLS,请将该值留空或设为none。注意
如果指定
none或tls以外的字符串,则 Kubernetes Operator 仍会将该项设置设为tls。
spec.security.authentication.ldap.userCacheInvalidationInterval类型:整型
指定 MongoDB 等待刷新 LDAP 用户缓存的秒数。默认为 30 秒。
spec.security.authentication.ldap.userToDNMapping类型:字符串
Maps the username provided to
mongodormongosfor authentication to an LDAP Distinguished Name (DN).有关详细信息,请参阅 MongoDB 手册中的security.ldap.userToDNMapping 。
spec.security.authentication.modes类型:数组
指定多 Kubernetes 集群 MongoDB 部署使用的身份验证机制。 有效值为
SCRAM、SCRAM-SHA-1、MONGODB-CR、X509和LDAP。 我们建议使用SCRAM-SHA-256 (SCRAM)而不是SCRAM-SHA-1。 如果指定SCRAM-SHA-1,则还必须指定MONGODB-CR。注意
To enable X.509 internal cluster authentication for the Cloud Manager or Ops Manager project, set this value to
["X509"]and specify the following settings:为spec.security.certsSecretPrefix提供一个值 设置。
如果您为
spec.security.authentication.modes提供多个值,则还必须为spec.security.authentication.agents.mode 指定一个值。
spec.security.authentication.requireClientTLSAuthentication类型:布尔值
默认:false
指定 MongoDB 主机是否要求客户端使用 TLS 证书进行连接。如果启用 TLS 身份验证,则默认为
true。要启用TLS身份验证,请为spec.security.certsSecretPrefix提供一个值 设置。
spec.security.certsSecretPrefix类型:字符串
Kubernetes 密钥 前缀的文本 您创建的,其中包含副本集的 TLS 密钥和证书。
您必须在密钥前面加上
<prefix>-<metadata.name>作为前缀。示例,如果调用部署
my-deployment并将前缀设置为mdb,则必须命名用于客户端 TLS 通信 的 TLSmdb-my-deployment-cert秘钥。此外,您必须命名用于内部集群身份验证(如果已启用)mdb-my-deployment-clusterfile的 TLS 密钥。要了解有关命名包含TLS证书的密钥的更多信息,请参阅多 Kubernetes 集群快速入门中适用于您的部署的主题。
spec.security.roles类型:数组
定义用户定义角色的数组,可对多 Kubernetes 集群 MongoDB 部署提供细粒度的访问控制。
To enable user-defined roles, the spec.security.authentication.enabled must be
true.例子
在此示例中,名为
customRole的用户定义角色允许用户将此角色分配给:在
pets数据库的cats集合中插入文档,以及查找文档并将其插入到
pets数据库的dogs集合中。
1 security: 2 authentication: 3 enabled: true 4 modes: 5 - "SCRAM" 6 roles: 7 - role: "customRole" 8 db: admin 9 privileges: 10 - actions: 11 - insert 12 resource: 13 collection: cats 14 db: pets 15 - actions: 16 - insert 17 - find 18 resource: 19 collection: dogs 20 db: pets 21 ...
spec.security.roles.authenticationRestrictions类型:数组
数组,用于定义分配有此spec.security.roles.role的用户可以连接的 IP 地址。
spec.security.roles.authenticationRestrictions.clientSource类型:数组
IP 地址或 CIDR 块的数组,分配有此spec.security.roles.role的用户可以从中进行连接。
如果请求来自此数组中不存在的客户端,则 MongoDB Server 会拒绝具有此角色的用户的连接请求。
spec.security.roles.authenticationRestrictions.serverAddress类型:数组
Array of IP addresses or CIDR blocks to which users assigned this spec.security.roles.role can connect.
如果客户端请求连接到该数组中不存在的服务器,则 MongoDB 服务器拒绝具有该角色的用户的连接请求。
spec.security.roles.db类型:字符串
存储用户定义角色的数据库。
例子
admin
spec.security.roles.privileges类型:数组
描述被授予此角色的用户所拥有特权的数组。
spec.security.roles.privileges.actions类型:数组
List of actions that users granted this role can perform. For a list of accepted values, see Privilege Actions in the MongoDB Manual for the MongoDB versions you deploy with the Kubernetes Operator.
spec.security.roles.privileges.resource类型:集合
Resources for which the privilege spec.security.roles.privileges.actions apply.
此集合必须包含以下任一项:
The spec.security.roles.privileges.resource.cluster setting with a value of
true.
spec.security.roles.privileges.resource.cluster类型:布尔值
默认:false
Flag that indicates that the privilege spec.security.roles.privileges.actions apply to all databases and collections in the MongoDB deployment.
如果设置为 true,则不要为spec.security.roles.privileges.resource.db和spec.security.roles.privileges.resource.collection 提供值。
spec.security.roles.privileges.resource.collection类型:字符串
Collection in the spec.security.roles.privileges.resource.db for which the privilege spec.security.roles.privileges.actions apply.
如果为此设置提供值,则还必须为spec.security.roles.privileges.resource.db 提供值。
spec.security.roles.privileges.resource.db类型:字符串
应用特权spec.security.roles.privileges.actions的数据库。
如果您为此设置提供值,则还必须为spec.security.roles.privileges.resource.collection 提供值。
spec.security.roles.role类型:字符串
用户定义角色的名称。
spec.security.tls.additionalCertificateDomains类型:集合
应添加到该部署中的每个 Pod 的 TLS 证书的每个域的列表。在您设置该参数时,Kubernetes Operator 转换为 TLS 证书的每个 CSR 都包含一个
<pod name>.<additional cert domain>格式的 SAN。Replica set resources don't need this parameter. Use spec.connectivity.replicaSetHorizons instead.
注意
如果您将此参数添加到启用 TLS 的资源,Kubernetes 将在资源达到
Pending状态时显示错误。显示此错误:Please manually remove the |csr| in order to proceed.要解决此问题:删除任何现有的 CSR,以便 Kubernetes 可以生成新的 CSR。如需了解如何删除资源,请参阅 Kubernetes 文档中的删除资源。
在 Kubernetes 生成 CSR 后批准它们。
spec.security.tls.ca类型:字符串
提供 ConfigMap 的名称 存储 CA 。
重要
如果使用自定义 CA 签署
MongoDBMultiCluster资源的 TLS 证书,则必须指定此参数。Kubernetes 操作符要求您在 ConfigMap 中为
MongoDBMultiCluster资源ca-pem的证书命名。
spec.security.tls.enabled类型:布尔值
重要
spec.security.tls.enabled已弃用,并将在未来的Kubernetes Operator发布中删除。要启用TLS,请为spec.security.certsSecretPrefix提供一个值设置。使用 TLS 证书对以下设备之间的通信进行加密:
副本集或分片集群配置中的 MongoDB 主机
Clients (
mongoshell, drivers, MongoDB Compass, and others) and the MongoDB deployment
spec.statefulSet.spec类型:集合
MongoDB Controllers for Kubernetes Operator 为您的多 Kubernetes集群MongoDB 部署创建的 StatefulSet 的全局规范。
要查看哪些字段可以添加到
spec.statefulSet.spec,请参阅Kubernetes文档中的 StatefulSetSpec v1 应用。