You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/deploy-configure.md
+76-2Lines changed: 76 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,10 @@ The [`/deploy/crds`](../deploy/crds) directory contains example MongoDB resource
6
6
7
7
-[Deploy a Replica Set](#deploy-a-replica-set)
8
8
-[Scale a Replica Set](#scale-a-replica-set)
9
-
-[Upgrade MongoDB Version & FCV](#upgrade-your-mongodb-resource-version-and-feature-compatibility-version)
10
-
-[Deploying on Openshift](#deploying-on-openshift)
9
+
-[Upgrade your MongoDB Resource Version and Feature Compatibility Version](#upgrade-your-mongodb-resource-version-and-feature-compatibility-version)
10
+
-[Example](#example)
11
+
-[Deploy Replica Sets on OpenShift](#deploy-replica-sets-on-openshift)
12
+
-[Define a Custom Database Role](#define-a-custom-database-role)
11
13
12
14
## Deploy a Replica Set
13
15
@@ -132,3 +134,75 @@ an example of how to provide the required configuration for a MongoDB
132
134
replica set.
133
135
134
136
See [here](../deploy/openshift/operator_openshift.yaml) for an example of how to configure the Operator deployment.
137
+
138
+
## Define a Custom Database Role
139
+
140
+
You can define [custom roles](https://docs.mongodb.com/manual/core/security-user-defined-roles/) to give you fine-grained access control over your MongoDB database resource.
141
+
142
+
**NOTE**: Custom roles are scoped to a single MongoDB database resource.
143
+
144
+
To define a custom role:
145
+
146
+
1. Add the following fields to the MongoDB resource definition:
147
+
148
+
| Key | Type | Description | Required? |
149
+
|----|----|----|----|
150
+
| `spec.security.roles` | array | Array that defines [custom roles](https://docs.mongodb.com/manual/core/security-user-defined-roles/) roles that give you fine-grained access control over your MongoDB deployment. | Yes |
151
+
| `spec.security.roles.role` | string | Name of the custom role. | Yes |
152
+
| `spec.security.roles.db` | string | Database in which you want to store the user-defined role. | Yes |
153
+
| `spec.security.roles.authenticationRestrictions` | array | Array that defines the IP address from which and to which users assigned this role can connect. | No |
154
+
| `spec.security.roles.authenticationRestrictions.clientSource` | array | Array of IP addresses or CIDR blocks from which users assigned this role can connect. <br><br> MongoDB servers reject connection requests from users with this role if the requests come from a client that is not present in this array. | No |
155
+
| `spec.security.roles.authenticationRestrictions.serverAddress` | array | Array of IP addresses or CIDR blocks to which users assigned this role can connect. <br><br> MongoDB servers reject connection requests from users with this role if the client requests to connect to a server that is not present in this array. | No |
156
+
| `spec.security.roles.privileges` | array | List of actions that users granted this role can perform. For a list of accepted values, see [Privilege Actions](https://docs.mongodb.com/manual/reference/privilege-actions/#database-management-actions) in the MongoDB Manual for the MongoDB versions you deploy with the Kubernetes Operator. | Yes |
157
+
| `spec.security.roles.privileges.actions` | array | Name of the role. Valid values are [built-in roles](https://docs.mongodb.com/manual/reference/built-in-roles/#built-in-roles). | Yes |
158
+
| `spec.security.roles.privileges.resource.database`| string | Database for which the privilege `spec.security.roles.privileges.actions` apply. An empty string (`""`) indicates that the privilege actions apply to all databases. <br><br> If you provide a value for this setting, you must also provide a value for `spec.security.roles.privileges.resource.collection`. | Conditional |
159
+
| `spec.security.roles.privileges.resource.collection`| string | Collection for which the privilege `spec.security.roles.privileges.actions` apply. An empty string (`""`) indicates that the privilege actions apply to all of the database's collections.<br><br> If you provide a value for this setting, you must also provide a value for `spec.security.roles.privileges.resource.database`. | Conditional |
160
+
| `spec.security.roles.privileges.resource.cluster`| string | Flag that indicates that the privilege `spec.security.roles.privileges.actions` apply to all databases and collections in the MongoDB deployment. If omitted, defaults to `false`.<br><br> If set to `true`, do not provide values for `spec.security.roles.privileges.resource.database` and `spec.security.roles.privileges.resource.collection`. | Conditional |
161
+
| `spec.security.roles.roles`| array | An array of roles from which this role inherits privileges. <br><br> You must include the roles field. Use an empty array (`[]`) to specify no roles to inherit from. | Yes |
162
+
| `spec.security.roles.roles.role` | string | Name of the role to inherit from. | Conditional |
163
+
| `spec.security.roles.roles.database` | string | Name of database that contains the role to inherit from. | Conditional |
164
+
165
+
```yaml
166
+
---
167
+
apiVersion: mongodb.com/v1
168
+
kind: MongoDB
169
+
metadata:
170
+
name: custom-role-mongodb
171
+
spec:
172
+
members: 3
173
+
type: ReplicaSet
174
+
version: "4.2.6"
175
+
security:
176
+
authentication:
177
+
modes: ["SCRAM"]
178
+
roles: # custom roles are defined here
179
+
- role: testRole
180
+
db: admin
181
+
privileges:
182
+
- resource:
183
+
db: "test"
184
+
collection: "" # an empty string indicates any collection
185
+
actions:
186
+
- find
187
+
roles: []
188
+
users:
189
+
- name: my-user
190
+
db: admin
191
+
passwordSecretRef: # a reference to the secret that will be used to generate the user's password
192
+
name: my-user-password
193
+
roles:
194
+
- name: clusterAdmin
195
+
db: admin
196
+
- name: userAdminAnyDatabase
197
+
db: admin
198
+
- name: testRole # apply the custom role to the user
Copy file name to clipboardExpand all lines: docs/users.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ You cannot disable SCRAM authentication.
40
40
| `spec.users.passwordSecretRef.key` | string| Key in the secret that corresponds to the value of the user's password. Defaults to `password`. | No |
41
41
| `spec.users.scramCredentialsSecretName` | string| ScramCredentialsSecretName appended by string "scram-credentials" is the name of the secret object created by the operator for storing SCRAM credentials for the user. The name should comply with [DNS1123 subdomain](https://tools.ietf.org/html/rfc1123). Also, please make sure the name is unique among `users`. | Yes |
42
42
| `spec.users.roles` | array of objects | Configures roles assigned to the user. | Yes |
43
-
| `spec.users.roles.role.name` | string | Name of the role. Valid values are [built-in roles](https://docs.mongodb.com/manual/reference/built-in-roles/#built-in-roles). | Yes |
43
+
| `spec.users.roles.role.name` | string | Name of the role. Valid values are [built-in roles](https://docs.mongodb.com/manual/reference/built-in-roles/#built-in-roles) and [custom roles](deploy-configure.md#define-a-custom-database-role) that you have defined. | Yes |
44
44
| `spec.users.roles.role.db` | string | Database that the role applies to. | Yes |
45
45
46
46
```
@@ -68,8 +68,8 @@ You cannot disable SCRAM authentication.
0 commit comments