ClusterMongoDBRole 自定义资源允许您配置用户访问 MongoDB 数据库所需的 角色。
例子
以下示例显示了ClusterMongoDBRole自定义资源的资源规范:
1 2 apiVersion: mongodb.com/v1 3 kind: ClusterMongoDBRole 4 metadata: 5 name: ldap-user-1 6 spec: 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 ...
所需的ClusterMongoDBRole 资源设置
spec.authenticationRestrictions类型:数组
定义分配此
spec.security.roles.role的用户可以连接的IP解决的数组。
spec.db类型:字符串
应用权限
spec.privileges.actions的数据库。如果您为此设置提供了值,则还必须为
spec.privileges.resource提供一个值。
spec.privileges.actions类型:数组
授予此角色的用户可以执行的操作列表。有关接受值的列表,请参阅使用Kubernetes Operator部署的MongoDB版本的MongoDB Server文档中的特权操作。
spec.privileges.resource类型:集合
特权
spec.privileges.actions适用的资源。此集合必须包含以下任一项:
spec.privileges.resource.db类型:字符串
应用权限
spec.privileges.actions的数据库。如果您为此设置提供了值,则还必须为
spec.privileges.resource.collection提供一个值。
spec.privileges.resource.collection类型:字符串
spec.privileges.resource.db中适用权限spec.privileges.actions的集合。如果您为此设置提供了值,则还必须为
spec.privileges.resource.db提供一个值。