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 进行通信。
持有凭证的 Ops Manager Kubernetes Secret 对象必须与您要创建的资源位于同一个命名空间中。
重要
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 独有设置。
如需了解可以使用哪些配置选项,请参阅 Ops Manager 文档中的“MongoDB 部署高级选项”。
spec.agent类型:集合
MongoDB 数据库资源的 MongoDB 助手配置设置。
spec.agent.startupOptions类型:集合
要用于启动 MongoDB database 资源的 MongoDB Agent 设置。
您必须以键值对形式提供 MongoDB 助手设置。这些值必须是字符串。 有关支持的 MongoDB 助手设置列表,请参阅:
云管理器项目的 MongoDB 代理设置。
使用 Kubernetes Operator 部署的 Ops Manager 版本的 MongoDB 助手设置。
spec.backup类型:集合
spec.backup.mode的集合容器, 可以对 Kubernetes Operator 中的 MongoDB 资源进行连续备份。
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类型:对象
包含 KMIP 备份加密配置设置的对象。要了解更多信息,请参阅为 Ops Manager 配置 KMIP 备份加密。
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.使用spec.backup.mode为 MongoDB 资源启用连续备份后, 您可以检查备份状态。
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类型:数字
使用 24 小时时钟安排快照的一天中的 UTC 小时。您可以设立介于
0和23(含)之间的值。
spec.backup.snapshotSchedule.referenceMinuteOfHour类型:数字
UTC minute of the hour to schedule snapshots. You can set a value between
0and59, inclusive.
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类型:字符串
spec.clusterSpecList类型:集合
MongoDBMultiCluster资源中每个 Kubernetes 集群的规范列表。
spec.clusterSpecList.clusterName类型:字符串
Name of the cluster where the MongoDB Controllers for Kubernetes Operator schedules the StatefulSet. When the Kubernetes Operator deploys this
MongoDBMultiClusterresource, it creates a service account. This name is what the service account in the operator cluster uses to communicate with the workload clusters.
spec.clusterSpecList.externalAccess.externalDomain类型:字符串
用于向外部公开您的副本集部署的外部域。
By default, each replica set member uses the Kubernetes Pod's FQDN (
*.svc.cluster.local) as the default hostname. However, if you add an external domain to this setting, the replica set uses a hostname that is a subdomain of the specified domain instead. This hostname uses the following format:<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 部署副本集时,才使用此设置。请参阅在没有服务网格的多集群中部署副本集。
spec.clusterSpecList.externalAccess.externalService类型:集合
用于在多 Kubernetes 集群 MongoDB 部署中向外部公开特定集群的配置。 这些设置会覆盖全局spec.externalAccess.externalService 设置。
When you set the spec.externalAccess setting, the Kubernetes Operator automatically creates an external load balancer service with default values. You can override certain values or add new values depending on your needs. For example, if you intend to create NodePort services and don't need a load balancer, you must configure overrides in your Kubernetes specification:
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类型:集合
Key-value pairs that let you add cloud provider-specific configuration settings to a specific cluster in your multi-Kubernetes cluster MongoDB deployment. This setting overrides the global setting, spec.externalAccess.externalService.annotations. To learn more, see annotations and the documentation for your Kubernetes cloud provider.
您可以使用注解为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}The StatefulSet. Equal to
{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类型:字符串
表示副本集节点成为主节点的相对可能性的数字。
要增加副本集节点成为主节点的相对可能性,请指定较高的
priority值。要降低副本集节点成为主节点的相对可能性,请指定较低的
priority值。
例如,
memberConfig.priority为1.5的成员比memberConfig.priority为0.5的成员更有可能成为主节点。memberConfig.priority为0的节点没有资格成为主节点。要了解更多信息,请参阅节点优先级。
spec.clusterSpecList.memberConfig.tags类型:地图
副本集标签映射,用于将读取和写入操作定向到您的 MongoDB 副本集的特定节点。
spec.clusterSpecList.memberConfig.votes类型:数字
Determines whether a MongoDB replica set member can vote in an election. Set to
1to allow the member to vote. Set to0to exclude the member from an election.
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. 中给定的值匹配。
为spec.security.certsSecretPrefix提供值 设置以启用TLS 。 这种使用水平分割的方法需要MongoDB Server TLS 协议的 名称指示扩展。
在此示例中,客户端使用
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
Specifies whether the Kubernetes Operator duplicates a Pod's service mesh object in each cluster to allow DNS resolution. Set to
falseif you configure a DNS proxy for your service mesh. For example, see DNS Proxying in the Istio documentation.
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.publishNotReadyAddresstrueSpecifies that DNS records are created even if the Pod isn't ready. Do not set to
falsefor any database Pod.注意
If you set spec.clusterSpecList.externalAccess.externalDomain, the external service adds another port (
Port Number + 1) for backups.
spec.externalAccess.externalService类型:集合
When you set the spec.externalAccess setting, the Kubernetes Operator automatically creates an external load balancer service with default values. You can override certain values or add new values depending on your needs. For example, if you intend to create NodePort services and don't need a load balancer, you must configure overrides in your Kubernetes specification:
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类型:集合
Key-value pairs that let you add cloud provider-specific configuration settings to all clusters in your multi-Kubernetes cluster MongoDB deployment. For cluster-specific overrides, see spec.clusterSpecList.externalAccess.externalService.annotations. To learn more, see annotations and the documentation for the cloud provider you use for Kubernetes deployments.
您可以使用注解为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}The StatefulSet. Equal to
{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
WARNING: Grant your containers permission to write to your Persistent Volume. The Kubernetes Operator sets
fsGroup = 2000,runAsUser = 2000, andrunAsNonRoot = trueinsecurityContext. Kubernetes Operator setsfsgroupequal torunAsUserto make the volume writable for a user that runs the main process in the container. To learn more, see Configure a Security Context for a Pod or Container and the related discussion in the Kubernetes documentation. If redeploying the resource doesn't fix issues with your Persistent Volume, contact MongoDB Support.If you do not use Persistent Volumes, the Disk Usage and Disk IOPS charts cannot be displayed in either the Processes tab on the Deployment page or in the Metrics page when reviewing the data for this deployment.
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类型:字符串
MongoDB 助手与多 Kubernetes 集群 MongoDB 部署交互时使用的用户名。 根据spec.security.authentication.ldap.userToDNMapping将用户名映射到 LDAP 标识名 (DN)。 生成的 DN 必须已存在于 LDAP 部署中。
This setting is required if spec.security.authentication.agents.mode is
LDAP.
spec.security.authentication.agents.clientCertificateSecretRef.name类型:字符串
默认:代理-certs
Specifies the secret that contains the MongoDB Agent's TLS certificate.
此密钥必须包含
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.
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类型:字符串
指定是否启用 X.509 内部集群身份验证。
要启用 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 和
spec.security.authentication.ldap.serversRFC4516 LDAP格式查询URL模板,用于获取用户所属的LDAP群组。该查询是相对于 中指定的一托管或多台主机的。您可以在模板中使用以下词元:{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 服务器时绑定的密码。
The secret must contain only one
passwordfield which stores the 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 身份验证所需。
LDAP 服务器的主机名和端口列表。按以下格式指定主机名及其相应的端口:
spec: security: authentication: ldap: servers: - "<hostname1>:<port1>" - "<hostname2>:<port2>"
spec.security.authentication.ldap.timeoutMS类型:整型
指定身份验证请求超时前应等待的毫秒数。
spec.security.authentication.ldap.transportSecurity类型:字符串
LDAP 身份验证所需。
指定 LDAP 服务器是否接受 TLS。
If the LDAP server accepts TLS, set the value to
tls. If the LDAP server doesn't accept TLS, leave this value blank or set the value tonone.注意
如果指定
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).For more details, see
security.ldap.userToDNMappingin the MongoDB Manual.
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。注意
要为Cloud Manager或Ops Manager项目启用X.509 内部集群身份验证,请将此值设立为
["X509"]并指定以下设置:为spec.security.certsSecretPrefix提供一个值 设置。
如果您为
spec.security.authentication.modes提供多个值,则还必须为spec.security.authentication.agents.mode 指定一个值。
spec.security.authentication.requireClientTLSAuthentication类型:布尔值
默认:false
Specifies whether the MongoDB host requires clients to connect using a TLS certificate. Defaults to
trueif you enable TLS authentication.要启用TLS身份验证,请为spec.security.certsSecretPrefix提供一个值 设置。
spec.security.certsSecretPrefix类型:字符串
Kubernetes 密钥 前缀的文本 您创建的,其中包含副本集的 TLS 密钥和证书。
您必须在密钥前面加上
<prefix>-<metadata.name>作为前缀。For example, if you call your deployment
my-deploymentand you set the prefix tomdb, you must name the TLS secret for the client TLS communicationsmdb-my-deployment-cert. Also, you must name the TLS secret for internal cluster authentication (if enabled)mdb-my-deployment-clusterfile.要了解有关命名包含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类型:数组
分配了此spec.security.roles.role的用户可以连接的 IP 地址或 CIDR 块的数组。
如果客户端请求连接到该数组中不存在的服务器,则 MongoDB 服务器拒绝具有该角色的用户的连接请求。
spec.security.roles.db类型:字符串
存储用户定义角色的数据库。
例子
admin
spec.security.roles.privileges类型:数组
描述被授予此角色的用户所拥有特权的数组。
spec.security.roles.privileges.actions类型:数组
被授予此角色的用户可以执行的动作列表。有关接受值的列表,请参阅《MongoDB 手册》中的特权动作,了解利用 Kubernetes Operator 可以部署的 MongoDB 版本。
spec.security.roles.privileges.resource类型:集合
特权spec.security.roles.privileges.actions适用的资源。
此集合必须包含以下任一项:
The spec.security.roles.privileges.resource.cluster setting with a value of
true.
spec.security.roles.privileges.resource.cluster类型:布尔值
默认:false
指示特权spec.security.roles.privileges.actions适用于 MongoDB 部署中的所有数据库和集合的标志。
如果设置为 true,则不要为spec.security.roles.privileges.resource.db和spec.security.roles.privileges.resource.collection 提供值。
spec.security.roles.privileges.resource.collection类型:字符串
spec.security.roles.privileges.resource.db中应用特权spec.security.roles.privileges.actions的集合。
如果为此设置提供值,则还必须为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类型:集合
List of every domain that should be added to TLS certificates to each Pod in this deployment. When you set this parameter, every CSR that the Kubernetes Operator transforms into a TLS certificate includes a SAN in the form
<pod name>.<additional cert domain>.副本集资源不需要此参数。 使用spec.connectivity.replicaSetHorizons 相反。
注意
If you add this parameter to a TLS-enabled resource, Kubernetes displays an error when the resource reaches the
Pendingstate. This error displays:Please manually remove the |csr| in order to proceed.To remedy this issue:删除任何现有的 CSR,以便 Kubernetes 可以生成新的 CSR。如需了解如何删除资源,请参阅 Kubernetes 文档中的删除资源。
在 Kubernetes 生成 CSR 后批准它们。
spec.security.tls.ca类型:字符串
提供 ConfigMap 的名称 存储 CA 。
重要
If you use a custom CA to sign your TLS certificates for the
MongoDBMultiClusterresource, you must specify this parameter.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 apps。