多 Kubernetes 集群资源规范
The MongoDBMultiCluster
resource defines your multi-Kubernetes cluster MongoDB deployment and gives the MongoDB Enterprise Kubernetes Operator the information it needs to create or update your clusters, Ops Manager deployment, StatefulSet, services, and other Kubernetes resources.
例子
以下示例显示了多 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: 4.4.0-ent 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 版本。重要
请务必选择兼容的 MongoDB Server 版本。
兼容版本因 MongoDB 数据库资源使用的基础图片而异。
注意
如果将此值更新到更高版本,请考虑设置spec.featureCompatibilityVersion以便在必要时为自己提供降级选项。
可选的MongoDBMultiCluster
资源设置
MongoDBMultiCluster
资源可以使用以下设置:
spec.additionalMongodConfig
类型:集合
启动 MongoDB 进程时需要使用的其他配置选项。
Kubernetes Operator 支持您通过 MongoDB 助手部署的 MongoDB 版本所支持的所有配置选项,但 Kubernetes Operator 会覆盖您为以下任何选项提供的值:
net.port
net.tls.certificateKeyFile
net.tls.clusterFile
net.tls.PEMKeyFile
replication.replSetName
security.clusterAuthMode
sharding.clusterRole
storage.dbPath
systemLog.destination
systemLog.path
要详细了解 Kubernetes Operator 拥有的配置选项,请参阅 MongoDB Kubernetes Operator 独有设置。
如需了解可以使用哪些配置选项,请参阅 Ops Manager 文档中的“MongoDB 部署高级选项”。
spec.agent
类型:集合
MongoDB 数据库资源的 MongoDB 助手配置设置。
spec.agent.startupOptions
类型:集合
要用于启动 MongoDB database 资源的 MongoDB Agent 设置。
您必须以键值对形式提供 MongoDB 助手设置。这些值必须是字符串。 有关支持的 MongoDB 助手设置列表,请参阅:
云管理器项目的 MongoDB 代理设置。
MongoDB Agent Operator 部署的MongoDB Ops Manager版本的 MongoDB Kubernetes 。
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
类型:布尔值
标志,指示在您删除
MongoDBMultiCluster
资源时 Kubernetes Operator 是否停止并终止备份。 默认值为false
。 当您想要在spec.backup.mode设置为
enabled
的情况下删除MongoDBMultiCluster
资源时,将此标志设置为true
非常有用。
spec.backup.encryption
类型:对象
包含备份加密配置设置的对象。
spec.backup.encryption.kmip
类型:对象
包含 KMIP 备份加密配置设置的对象。如需了解更多信息,请参阅为 Ops Manager 配置 KMIP 备份加密。
spec.backup.encryption.kmip.client
类型:对象
包含 KMIP 备份加密客户端配置设置的对象。
spec.backup.mode
类型:字符串
为
MongoDBMultiCluster
资源启用连续备份。 可能的值为enabled
、disabled
和terminated
。注意
spec.backup.mode 设置依赖于 MongoDB Ops Manager
spec.backup.enabled
中启用的 备份 ,并要求将MongoDB Ops Manager 资源规范 中的 值设置为true
。使用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
类型:数字
一天中的 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
类型:字符串
spec.clusterSpecList
类型:集合
MongoDBMultiCluster
资源中每个 Kubernetes 集群的规范列表。
spec.clusterSpecList.clusterName
类型:字符串
MongoDB Enterprise Kubernetes Operator 调度 StatefulSet 的集群的名称 。当 Kubernetes Operator 部署此
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.com
使用此设置部署副本集后, Kubernetes Operator 使用带有外部域的主机名来覆盖MongoDB Ops Manager自动化配置
中的
processes[n].hostname
字段。 然后, MongoDB Agent会使用此主机名连接到mongod
。要指定用于连接到副本集的其他主机名,可以使用
spec.connectivity.replicaSetHorizons
设置。但是,以下连接仍会使用包含外部域的主机名:警告:指定此字段会更改MongoDB Ops Manager注册
mongod
进程的方式。 只能为从Kubernetes Operator 版本1.19开始的新副本集部署指定此字段。 您无法更改此字段的值,也无法更改运行的副本集部署的MongoDB Ops Manager自动化配置中的任何processes[n].hostname
字段。重要
仅当在没有服务网格的情况下部署多 Kubernetes 集群 MongoDB 部署副本集时,才使用此设置。 请参阅在没有服务网格的多 Kubernetes 集群中部署副本集。
spec.clusterSpecList.externalAccess.externalService
类型:集合
用于在多 Kubernetes 集群 MongoDB 部署中向外部公开特定集群的配置。 这些设置会覆盖全局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.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}
{clusterIndex}
Kubernetes Operator 最初为 spec.clusterSpecList.clusterName 中设立的当前集群名称分配的索引。
此值可能无法反映 spec.clusterSpecList 中定义的成员集群的顺序。尽管您可以更改 spec.clusterSpecList 中成员集群的顺序,但Kubernetes Operator 仍使用最初为当前集群名称分配的索引。
{statefulSetName}
StatefulSet 。等于
{resourceName}-{clusterIndex}
。{externalServiceName}
根据指定的占位符值生成的外部服务名称。 等于
{resourceName}-{clusterIndex}-{podIndex}-svc-external
。{mongodProcessDomain}
托管mongod进程的服务器的域名。 等于 spec.externalAccess.externalDomain如果已指定。 否则,等于用于
mongod
进程FQDN 的域。例如,对于进程主机名
mdb-rs-1.example.com
,example.com
是域名。{mongodProcessFQDN}
进程主机名取决于您的部署配置。 如果您已将多 Kubernetes集群MongoDB 部署配置为使用 外部域 ,例如没有服务网格的部署,则进程主机名使用以下格式:
{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: 4.4.0-ent 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
类型:字符串
表示 MongoDB 副本集成员成为主节点的相对可能性的数字。
要增加副本集节点成为主节点的相对可能性,请指定较高的
priority
值。要降低副本集节点成为主节点的相对可能性,请指定较低的
priority
值。
例如,
memberConfig.priority
为1.5
的成员比memberConfig.priority
为0.5
的成员更有可能成为主节点。memberConfig.priority
为0
的节点没有资格成为主节点。 要了解更多信息,请参阅成员优先级。
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 Enterprise Kubernetes Operator 不会删除或重新创建该服务。 通过此设置,您可以创建自己的自定义服务,并允许 Kubernetes Operator 重复使用这些服务。
spec.clusterSpecList.statefulSet.spec
类型:集合
为 StatefulSet 提供配置 覆盖多 Kubernetes 集群 MongoDB 部署中集群的每个 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 。 这种使用水平分割的方法需要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
指定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
外部服务的名称。您无法更改此值。
Type
LoadBalancer
创建外部 LoadBalancer 服务。
Port
<Port Number>
mongod
的端口。publishNotReadyAddress
true
指定 DNS 记录 即使 Pod 尚未准备就绪,也会创建。对于任何数据库 Pod,请勿设置为
false
。注意
如果设置spec.clusterSpecList.externalAccess.externalDomain ,则外部服务会添加另一个端口 (
Port Number + 1
) 用于备份。
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}
{clusterIndex}
Kubernetes Operator 最初为 spec.clusterSpecList.clusterName 中设立的当前集群名称分配的索引。
此值可能无法反映 spec.clusterSpecList 中定义的成员集群的顺序。尽管您可以更改 spec.clusterSpecList 中成员集群的顺序,但Kubernetes Operator 仍使用最初为当前集群名称分配的索引。
{statefulSetName}
StatefulSet 。等于
{resourceName}-{clusterIndex}
。{externalServiceName}
根据指定的占位符值生成的外部服务名称。 等于
{resourceName}-{clusterIndex}-{podIndex}-svc-external
。{mongodProcessDomain}
托管mongod进程的服务器的域名。 等于 spec.externalAccess.externalDomain如果已指定。 否则,等于用于
mongod
进程FQDN 的域。例如,对于进程主机名
mdb-rs-1.example.com
,example.com
是域名。{mongodProcessFQDN}
进程主机名取决于您的部署配置。 如果您已将多 Kubernetes集群MongoDB 部署配置为使用 外部域 ,例如没有服务网格的部署,则进程主机名使用以下格式:
{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
类型:数字
限制升级到新的主要版本时发生的数据更改。 这允许您降级到以前的主要版本。 要了解有关功能兼容性的更多信息,请参阅 MongoDB 手册中的
setFeatureCompatibilityVersion
。
spec.logLevel
类型:字符串
配置 Pod 内自动化代理日志记录的级别。接受的值包括:
DEBUG
INFO
WARN
ERROR
FATAL
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 在 中设置
fsGroup = 2000
、runAsUser = 2000
和runAsNonRoot = true
securityContext
。Kubernetes Operator 将fsgroup
设置为等于runAsUser
,以使在容器中运行主进程的用户可写入该卷。 要学习;了解更多信息,请参阅 为 Pod 或容器配置安全上下文 以及相关 讨论 在Kubernetes文档中。如果重新部署资源无法解决持久卷的问题,请联系MongoDB支持部门。Disk UsageDisk IOPSAtlas Charts如果不使用Processes DeploymentMetrics持久卷 ,在 查看此部署的数据 时, 和 无法显示在 页面上的 标签页中,也无法显示在 页面中。
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.automationPasswordSecretRef
类型:集合
密钥 的详细信息 包含 spec.security.authentication.agents.automationUserName 的密码用户。
如果spec.security.authentication.agents.mode为
LDAP
,则需要此设置。
spec.security.authentication.agents.automationPasswordSecretRef.key
类型:字符串
键入 spec.security.authentication.agents.automationPasswordSecretRef.name 密钥 包含 spec.security.authentication.agents.automationUserName 中用户的密码。
如果spec.security.authentication.agents.mode为
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 。
如果spec.security.authentication.agents.mode为
LDAP
,则需要此设置。
spec.security.authentication.agents.automationPasswordSecretRef.optional
类型:布尔值
指定这些选项是必需还是可选的:
spec.security.authentication.agents.automationUserName
类型:字符串
MongoDB 助手与多 Kubernetes 集群 MongoDB 部署交互时使用的用户名。 根据spec.security.authentication.ldap.userToDNMapping将用户名映射到 LDAP 标识名 (DN)。 生成的 DN 必须已存在于 LDAP 部署中。
如果spec.security.authentication.agents.mode为
LDAP
,则需要此设置。
spec.security.authentication.agents.clientCertificateSecretRef.name
类型:字符串
默认:代理-certs
指定 MongoDB Agent密钥 包含 的 TLS 证书。
此密钥必须包含以下密钥,其值是可以由服务器验证的 TLS 证书:
mms-automation-agent-pem
mms-backup-agent-pem
mms-monitoring-agent-pem
必须在部署 Kubernetes Operator 的同一命名空间中创建此密钥:
kubectl create secret generic agent-certs \ --from-file=mms-automation-agent-pem=<automation-cert.pem> \ --from-file=mms-backup-agent-pem=<backup-cert.pem> \ --from-file=mms-monitoring-agent-pem=<monitoring-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
类型:字符串
多 Kubernetes 集群 MongoDB 部署的 MongoDB 助手使用的身份验证机制。 有效值为
SCRAM
、SCRAM-SHA-1
、MONGODB-CR
、X509
和LDAP
。 您指定的值还必须存在于spec.security.authentication.modes中。 我们建议使用SCRAM-SHA-256 (SCRAM)
而不是SCRAM-SHA-1
。 如果指定SCRAM-SHA-1
,则还必须指定MONGODB-CR
。
spec.security.authentication.ignoreUnknownUsers
类型:布尔值
默认:false
确定是否可以修改未通过 Kubernetes Operator、Cloud Manager 或 Ops Manager 用户界面配置的数据库用户。
spec.security.authentication.internalCluster
类型:字符串
指定是否启用X. 509内部集群身份验证。
要启用 X.509 内部集群身份验证,请设置为
"X509"
。要求指定以下设置:Kubernetes Operator 接受以下值:
["X509"]
:X. 509内部集群身份验证已启用。""
或省略:未启用内部集群身份验证。
重要
启用内部集群身份验证后,就无法再将其禁用。
spec.security.authentication.ldap
类型:集合
LDAP 身份验证所需。
为 或 LDAP项目配置 身份验证。Cloud ManagerMongoDB Ops Manager要启用LDAP身份验证,请设立spec.security。身份验证.modes为
["LDAP"]
。
spec.security.authentication.ldap.authzQueryTemplate
类型:字符串
是 LDAP 授权所必需的。
RFC4515 和 RFC4516 MongoDB 执行的 LDAP 格式查询 URL 模板,用于获取用户所属的 LDAP 群组。该查询相对于
spec.security.authentication.ldap.servers
中指定的一个或多个主机。 您可以在模板中使用以下词元:{USER}
- 将经过身份验证的用户名或
transformed
用户名替换到 LDAP 查询中。
{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 身份验证所需。
LDAP 服务器的主机名和端口列表。按以下格式指定主机名及其相应的端口:
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
类型:字符串
将提供给
mongod
或mongos
进行身份验证的用户名映射到 LDAP 标识名 (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
。注意
要为 509Cloud Manager或MongoDB Ops Manager 项目启用 X. 内部集群身份验证 ,请将此值设置为
["X509"]
并指定以下设置:为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
密钥。此外,您必须命名用于内部集群身份验证(如果已启用)的TLS密钥mdb-my-deployment-clusterfile
。要了解有关命名包含TLS证书的密钥的更多信息,请参阅多 Kubernetes 集群快速入门中适用于您的部署的主题。
spec.security.roles
类型:数组
定义用户定义角色的数组,可对多 Kubernetes 集群 MongoDB 部署提供细粒度的访问控制。
要启用用户定义的角色, spec.security.authentication.enabled必须为
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
类型:数组
授予此角色的用户可以执行的操作列表。 有关接受值的列表,请参阅使用 Kubernetes Operator 部署的 MongoDB 版本的 MongoDB 手册中的特权操作。
spec.security.roles.privileges.resource
类型:集合
特权spec.security.roles.privileges.actions适用的资源。
此集合必须包含以下任一项:
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
类型:集合
应添加到该部署中的每个 Pod 的 TLS 证书的每个域的列表。在您设置该参数时,Kubernetes Operator 转换为 TLS 证书的每个 CSR 都包含一个
<pod name>.<additional cert domain>
格式的 SAN。
副本集资源不需要此参数。 使用spec.connectivity.replicaSetHorizons 相反。
注意
如果您将此参数添加到启用 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
类型:布尔值
重要
从Kubernetes Operator 版本1.19开始,
spec.security.tls.enabled
已弃用,并将在未来的Kubernetes Operator发布中删除。 要启用TLS ,请为spec.security.certsSecretPrefix提供一个值 设置。使用 TLS 证书对以下设备之间的通信进行加密:
副本集或分片集群配置中的 MongoDB 主机
客户端(
mongo
shell 、驱动程序、 MongoDB Compass等)和MongoDB部署
spec.statefulSet.spec
类型:集合
StatefulSet 的全局规范 MongoDB Enterprise Kubernetes Operator 为您的多 Kubernetes 集群 MongoDB 部署创建的。
要查看可以添加到
spec.statefulSet.spec
的字段,请参阅 StatefulSetSpec v1 apps 在 Kubernetes 文档中。