|
| 1 | +--- |
| 2 | +ref: configure-kubectl-user |
| 3 | +stepnum: 1 |
| 4 | +inherit: |
| 5 | + file: steps-configure-kubectl-namespace.yaml |
| 6 | + ref: configure-kubectl-namespace |
| 7 | +--- |
| 8 | +title: "Copy the following example |k8s-crd|." |
| 9 | +level: 4 |
| 10 | +stepnum: 2 |
| 11 | +ref: copy-k8s-user-crd |
| 12 | +content: | |
| 13 | +
|
| 14 | + .. literalinclude:: /reference/k8s/example-ldap-user.yaml |
| 15 | + :language: yaml |
| 16 | +
|
| 17 | +--- |
| 18 | +title: "Open your preferred text editor and paste the example |k8s-crd| into a new text file." |
| 19 | +stepnum: 3 |
| 20 | +level: 4 |
| 21 | +ref: paste-k8s-crd |
| 22 | +--- |
| 23 | +title: "Change the lines for the following parameters, as needed." |
| 24 | +level: 4 |
| 25 | +stepnum: 4 |
| 26 | +ref: change-k8s-user-crd |
| 27 | +content: | |
| 28 | +
|
| 29 | + Use the following table to guide you through changing the relevant |
| 30 | + lines in the|k8s-crd|. For a full list of LDAP user settings, see |
| 31 | + :ref:`security settings <security-settings>` in the |k8s-op-short| |
| 32 | + MongoDB resource specification. |
| 33 | +
|
| 34 | + .. list-table:: |
| 35 | + :widths: 20 10 50 20 |
| 36 | + :header-rows: 1 |
| 37 | +
|
| 38 | + * - Key |
| 39 | + - Type |
| 40 | + - Description |
| 41 | + - Example |
| 42 | +
|
| 43 | + * - ``metadata.name`` |
| 44 | + - string |
| 45 | + - The name of the resource for the MongoDB database user. |
| 46 | +
|
| 47 | + .. include:: /includes/fact-resource-name-char-limit.rst |
| 48 | + |
| 49 | + - ``ldap-user-1`` |
| 50 | +
|
| 51 | + * - ``spec.db`` |
| 52 | + - string |
| 53 | + - The name of the MongoDB database where users will be added. This |
| 54 | + value must be ``$external``. |
| 55 | + - ``$external`` |
| 56 | +
|
| 57 | + * - ``spec.mongodbResourceRef.name`` |
| 58 | + - string |
| 59 | + - The name of the :ref:`MongoDB resource <k8s-deploy-mdb-resources>` |
| 60 | + to which this user is associated. |
| 61 | + - ``my-resource`` |
| 62 | +
|
| 63 | + * - ``spec.opsManager.configMapRef.name`` |
| 64 | + - string |
| 65 | + - The name of the project containing the MongoDB database |
| 66 | + where the user will be added. The |
| 67 | + :setting:`spec.cloudManager.configMapRef.name` setting is an |
| 68 | + alias for this setting and can be used in its place. |
| 69 | + - ``my-project`` |
| 70 | +
|
| 71 | + * - ``spec.roles.db`` |
| 72 | + - string |
| 73 | + - The database the :ref:`role <roles>` can act on. |
| 74 | + - ``admin`` |
| 75 | +
|
| 76 | + * - ``spec.roles.name`` |
| 77 | + - string |
| 78 | + - The name of the :ref:`role <roles>` to grant the database user. |
| 79 | + The role name can be any :ref:`built-in MongoDB role <built-in-roles>` |
| 80 | + or :opsmgr:`custom role </tutorial/manage-mongodb-roles>` that |
| 81 | + exists in |com|. |
| 82 | + - ``readWriteAnyDatabase`` |
| 83 | +
|
| 84 | + * - ``spec.username`` |
| 85 | + - string |
| 86 | + - The authenticated username that is mapped to an LDAP Distinguished |
| 87 | + Name (DN) according to |
| 88 | + :setting:`spec.security.authentication.ldap.userToDNMapping`. |
| 89 | + The DN must already exist in your LDAP deployment. |
| 90 | + This username must comply with the `RFC 2253 <https://tools.ietf.org/html/rfc2253>`__ |
| 91 | + LDAPv3 Distinguished Name standard. :setting:`transformed <security.ldap.userToDNMapping>` |
| 92 | + |
| 93 | + To learn more, see |
| 94 | + :manual:`LDAP Query Templates |
| 95 | + </core/security-ldap-external/#ldap-query-template>` in the |
| 96 | + MongoDB Manual. |
| 97 | + - ``uid=mdb0,dc=example,dc=org`` |
| 98 | +
|
| 99 | +
|
| 100 | +--- |
| 101 | +title: "Add any additional roles for the user to the |k8s-crd|." |
| 102 | +level: 4 |
| 103 | +stepnum: 5 |
| 104 | +ref: add-additional-roles-k8s-user |
| 105 | +content: | |
| 106 | + You may grant additional roles to this user using the format defined |
| 107 | + in the following example: |
| 108 | +
|
| 109 | + .. code-block:: yaml |
| 110 | + :copyable: false |
| 111 | +
|
| 112 | + --- |
| 113 | + apiVersion: mongodb.com/v1 |
| 114 | + kind: MongoDBUser |
| 115 | + metadata: |
| 116 | + name: ldap-user-1 |
| 117 | + spec: |
| 118 | + username: "uid=mdb0,dc=example,dc=org" |
| 119 | + db: "$external" |
| 120 | + mongodbResourceRef: |
| 121 | + name: ldap-replica-set |
| 122 | + roles: |
| 123 | + - db: "admin" |
| 124 | + name: "clusterAdmin" |
| 125 | + - db: "admin" |
| 126 | + name: "readWriteAnyDatabase" |
| 127 | + - db: "admin" |
| 128 | + name: "dbAdminAnyDatabase" |
| 129 | +
|
| 130 | + ... |
| 131 | +
|
| 132 | +--- |
| 133 | +title: "Create the user." |
| 134 | +level: 4 |
| 135 | +stepnum: 6 |
| 136 | +ref: create-k8s-user |
| 137 | +content: | |
| 138 | +
|
| 139 | + Invoke the following |k8s| command to create your database user: |
| 140 | +
|
| 141 | + .. code-block:: sh |
| 142 | +
|
| 143 | + kubectl apply -f <database-user-conf>.yaml |
| 144 | +
|
| 145 | + The following examples illustrate the connection string formats that you |
| 146 | + can use when enabling authentication with LDAP in |k8s-op-short| MongoDB |
| 147 | + deployments. These examples use the ``mongodb`` namespace and a replica |
| 148 | + set deployment named ``replica-set-ldap``. The examples are similar for |
| 149 | + sharded clusters. |
| 150 | +
|
| 151 | + - ``connectionString.standard``::manual:`Standard connection string |
| 152 | + </reference/connection-string#std-label-connections-standard-connection-string-format>` |
| 153 | + that can connect you to the database as this database user. |
| 154 | +
|
| 155 | + .. code-block:: sh |
| 156 | +
|
| 157 | + mongodb://replica-set-ldap-0-0-svc.mongodb.svc.cluster.local/?connectTimeoutMS=20000&replicaSet=replica-set-ldap&serverSelectionTimeoutMS=20000&ssl=true&authSource=$external |
| 158 | +
|
| 159 | + - ``connectionString.standardSrv``: :manual:`DNS seed list connection string |
| 160 | + </reference/connection-string/#dns-seed-list-connection-format>` that |
| 161 | + can connect you to the database as this database user. |
| 162 | +
|
| 163 | + .. code-block:: sh |
| 164 | +
|
| 165 | + mongodb+srv://replica-set-ldap-svc.mongodb.svc.cluster.local/?connectTimeoutMS=20000&replicaSet=replica-set-ldap&serverSelectionTimeoutMS=20000&ssl=true&authSource=$external |
| 166 | +
|
| 167 | + Using the previously-shown formats, you can connect to the MongoDB |
| 168 | + database with the MongoDB Shell (``mongosh``), as in the following |
| 169 | + example: |
| 170 | +
|
| 171 | + .. code-block:: sh |
| 172 | +
|
| 173 | + mongosh <connection-string> \ |
| 174 | + --host <my-replica-set>/web1.example.com \ |
| 175 | + --port 30907 \ |
| 176 | + --authenticationMechanism PLAIN \ |
| 177 | + --username cn=rob,cn=Users,dc=ldaps-01,dc=myteam,dc=com |
| 178 | +
|
| 179 | + You can use these credentials to |
| 180 | + :ref:`connect to a MongoDB Database Resource from Inside Kubernetes <connect-from-inside-k8s>`. |
| 181 | +
|
| 182 | +--- |
| 183 | +title: "View the newly created user in |com|." |
| 184 | +level: 4 |
| 185 | +stepnum: 7 |
| 186 | +ref: view-k8s-user |
| 187 | +content: | |
| 188 | +
|
| 189 | + You can view the newly-created user in |com|: |
| 190 | +
|
| 191 | + 1. From the Project's :guilabel:`Deployment` view, click |
| 192 | + the :guilabel:`Security` tab. |
| 193 | +
|
| 194 | + #. Click the :guilabel:`MongoDB Users` nested tab. |
| 195 | +
|
| 196 | +... |
0 commit comments