|
| 1 | +.. _configuration: |
| 2 | + |
| 3 | +============================ |
| 4 | +Configure the |k8s-op-short| |
| 5 | +============================ |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 1 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +After |
| 16 | +:doc:`installing the {+k8s-op-short+} </tutorial/install-k8s-operator>`, |
| 17 | +you will need to perform both of the following configurations before |
| 18 | +deploying MongoDB database resources: |
| 19 | + |
| 20 | +- :ref:`create-k8s-project` |
| 21 | + |
| 22 | +- :ref:`create-k8s-credentials` |
| 23 | + |
| 24 | +.. _create-k8s-project: |
| 25 | + |
| 26 | +Create your |onprem| Project using a |k8s| |k8s-configmap| |
| 27 | +---------------------------------------------------------- |
| 28 | + |
| 29 | +The |k8s-op-full| uses a |k8s| |k8s-configmap| to link to your |
| 30 | +|onprem| :opsmgr:`Project </tutorial/manage-projects>`. To create a |
| 31 | +|k8s-op-short| ConfigMap, you need to edit 4 lines of the |
| 32 | +:ref:`example ConfigMap <example-k8s-configmap>` |yaml| file and apply |
| 33 | +the ConfigMap: |
| 34 | + |
| 35 | +1. Copy the following :ref:`example ConfigMap <example-k8s-configmap>`. |
| 36 | + |
| 37 | + .. _example-k8s-configmap: |
| 38 | + |
| 39 | + .. literalinclude:: /reference/k8s/example-configmap.yaml |
| 40 | + :language: yaml |
| 41 | + :emphasize-lines: 5-6, 8-10 |
| 42 | + |
| 43 | +#. Open your preferred text editor and paste the example |
| 44 | + |k8s-configmap| into a new text file. |
| 45 | + |
| 46 | +#. Change the following four lines: |
| 47 | + |
| 48 | + .. list-table:: |
| 49 | + :widths: 20 20 40 20 |
| 50 | + :header-rows: 1 |
| 51 | + |
| 52 | + * - Key |
| 53 | + - Type |
| 54 | + - Description |
| 55 | + - Example |
| 56 | + |
| 57 | + * - ``metadata.name`` |
| 58 | + - string |
| 59 | + - Label for a |k8s| |k8s-obj|. |
| 60 | + |
| 61 | + .. seealso:: |
| 62 | + |
| 63 | + - :setting:`metadata.name` |
| 64 | + - |k8s| documentation on `names <https://kubernetes.io/docs/concepts/overview/working-with-objects/names/>`__. |
| 65 | + This name must follow :rfc:`RFC1123 <1123>` naming |
| 66 | + conventions, using only lowercase alphanumeric |
| 67 | + characters, '-' or '.', and must start and end with an |
| 68 | + alphanumeric character. |
| 69 | + |
| 70 | + - ``myconfigmap`` |
| 71 | + |
| 72 | + * - ``metadata.namespace`` |
| 73 | + - string |
| 74 | + - Scope of object names. Used to limit what can be managed to |
| 75 | + a subset of all |k8s-objs|. The default value is ``mongodb``. |
| 76 | + |
| 77 | + .. important:: |
| 78 | + The |k8s-op-short|, |k8s-secret|, and |k8s-mdbrsc|\s |
| 79 | + *must* be created in the same |k8s-ns|. |
| 80 | + |
| 81 | + .. seealso:: |
| 82 | + |
| 83 | + - :setting:`metadata.namespace` |
| 84 | + - |k8s| documentation on |k8s-nss| |
| 85 | + |
| 86 | + - ``mongodb`` |
| 87 | + |
| 88 | + * - ``data.projectName`` |
| 89 | + - string |
| 90 | + - Label for your |mms| |
| 91 | + :opsmgr:`Project </tutorial/manage-projects>`. |
| 92 | + |
| 93 | + .. admonition:: Let |k8s-op-short| create the Project |
| 94 | + :class: important |
| 95 | + |
| 96 | + The |k8s-op-short| creates the |mms| Project if it does |
| 97 | + not exist. It is **strongly recommended** to use the |
| 98 | + Operator to create a new Project for |k8s| to manage. The |
| 99 | + Operator adds additional internal information to Projects |
| 100 | + that it creates. |
| 101 | + |
| 102 | + If you need or want to use an existing Project, you can find |
| 103 | + the ``projectName`` by clicking the :guilabel:`All Clusters` |
| 104 | + link at the top left of the screen, then either search by |
| 105 | + name in the :guilabel:`Search` box or scroll to find the |
| 106 | + name in the list. Each card in this list represents the |
| 107 | + combination of one **Organization** and **Project**. |
| 108 | + |
| 109 | + - ``Development`` |
| 110 | + |
| 111 | + * - ``data.orgId`` |
| 112 | + - string |
| 113 | + - 24 character hex string that uniquely identifies your |
| 114 | + MongoDB :opsmgr:`Organization </tutorial/manage-organizations>`. |
| 115 | + You can find the ``orgId`` in your |onprem| |url|: |
| 116 | + |
| 117 | + 1. Click the :guilabel:`Context` menu. |
| 118 | + 2. Select your Organization. |
| 119 | + 3. View the current |url| in your |
| 120 | + browser and copy the value |
| 121 | + displayed in the ``<orgId>`` |
| 122 | + placeholder below: |
| 123 | + |
| 124 | + | ``https://ops.example.com:8443/`` |
| 125 | + | ``v2#/org/<orgId>/projects`` |
| 126 | + |
| 127 | + .. important:: |
| 128 | + |
| 129 | + This field is *optional*. If you omit the ``orgId``, |
| 130 | + |onprem| creates an Organization called ``projectName`` |
| 131 | + that contains a Project also called ``projectName``. |
| 132 | + |
| 133 | + You must have the :authrole:`Organization Project Creator` |
| 134 | + role to create a new project |
| 135 | + *within an existing organization*. |
| 136 | + |
| 137 | + .. admonition:: Limited to Cloud or Ops Manager Organizations |
| 138 | + |
| 139 | + If you set this value, it can be for a Cloud Manager or |
| 140 | + an Ops Manager organization only. If you try to use an |
| 141 | + Atlas organization, the |k8s-op-short| may not work as |
| 142 | + intended. |
| 143 | + |
| 144 | + - | ``5cc9b333dd3e384a625a6615`` |
| 145 | + |
| 146 | + * - ``data.baseUrl`` |
| 147 | + - string |
| 148 | + - |url| to your |application| including the |fqdn| and port |
| 149 | + number. |
| 150 | + |
| 151 | + .. note:: |
| 152 | + |
| 153 | + You may use |cloud-short| for the ``data.baseUrl`` value. |
| 154 | + |
| 155 | + - ``https://ops.example.com:8443`` |
| 156 | + |
| 157 | +#. Save this file with a ``.yaml`` file extension. |
| 158 | + |
| 159 | +#. Invoke the following |k8s| command to create your |k8s-configmap|: |
| 160 | + |
| 161 | + .. code-block:: sh |
| 162 | + |
| 163 | + kubectl apply -f <myconfigmap.yaml> |
| 164 | + |
| 165 | + .. important:: |
| 166 | + |
| 167 | + All subsequent ``kubectl`` commands you invoke must add the |
| 168 | + ``-n`` option with the :setting:`metadata.namespace` you |
| 169 | + specified in your |k8s-configmap|. |
| 170 | + |
| 171 | +#. Invoke the following |k8s| command to verify your |k8s-configmap|: |
| 172 | + |
| 173 | + .. code-block:: sh |
| 174 | + |
| 175 | + kubectl describe configmaps <myconfigmap> -n <metadata.namespace> |
| 176 | + |
| 177 | + .. admonition:: *Always include the namespace option with* ``kubectl`` |
| 178 | + :class: important |
| 179 | + |
| 180 | + |kubectl| defaults to an empty namespace if you do not specify |
| 181 | + the ``-n`` option, resulting in deployment failures. You must |
| 182 | + specify the value of the ``<metadata.namespace>`` field. |
| 183 | + The |k8s-op-short|, |k8s-secret|, and |k8s-mdbrsc|\s should |
| 184 | + run in the same unique namespace. |
| 185 | + |
| 186 | + This command returns a ConfigMap description in the shell: |
| 187 | + |
| 188 | + .. code-block:: sh |
| 189 | + |
| 190 | + Name: <myconfigmap> |
| 191 | + Namespace: <metadata.namespace> |
| 192 | + Labels: <none> |
| 193 | + Annotations: <none> |
| 194 | + |
| 195 | +.. _create-k8s-credentials: |
| 196 | +.. _create-k8s-secret: |
| 197 | + |
| 198 | +Create a |k8s| Secret to Allow the Operator to Manage the Project |
| 199 | +----------------------------------------------------------------- |
| 200 | + |
| 201 | +For the |k8s-op-short| to create or update |k8s-objs| in your |onprem| |
| 202 | +Project, you need to store your username and |
| 203 | +:ref:`Public API Key <generate-public-api-key>` as a |k8s| |
| 204 | +|k8s-secret|. Creating a secret stores authentication credentials so |
| 205 | +only |k8s| can access them. |
| 206 | + |
| 207 | +Multiple secrets can exist in the same namespace. Each user should |
| 208 | +have their own secret. |
| 209 | + |
| 210 | +To create your |k8s| secret: |
| 211 | + |
| 212 | +1. Make sure you have your |onprem| username and Public API Key. |
| 213 | + |
| 214 | + If you do not have your Public API Key, you need to generate a new |
| 215 | + :ref:`Public API Key <generate-public-api-key>`. |
| 216 | + |
| 217 | +2. Invoke the following |k8s| command to create your secret: |
| 218 | + |
| 219 | + .. code-block:: sh |
| 220 | + |
| 221 | + kubectl -n <metadata.namespace> \ |
| 222 | + create secret generic <myCredentials> \ |
| 223 | + --from-literal="user=< [email protected]>" \ |
| 224 | + --from-literal="publicApiKey=<my-public-api-key>" |
| 225 | + |
| 226 | + .. note:: |
| 227 | + |
| 228 | + The ``-n`` flag limits the |k8s-ns| to which this secret |
| 229 | + applies. All MongoDB |k8s| resources must be in the same |
| 230 | + namespace with the |k8s-secrets| and |k8s-configmaps|. The |
| 231 | + |k8s-op-short| does not use either the secrets or ConfigMaps. |
| 232 | + |
| 233 | +3. Invoke the following |k8s| command to verify your secret: |
| 234 | + |
| 235 | + .. code-block:: sh |
| 236 | + |
| 237 | + kubectl describe secrets/<myCredentials> -n <metadata.namespace> |
| 238 | + |
| 239 | + This command returns a secret description in the shell: |
| 240 | + |
| 241 | + .. code-block:: sh |
| 242 | + |
| 243 | + Name: <myCredentials> |
| 244 | + Namespace: <metadata.namespace> |
| 245 | + Labels: <none> |
| 246 | + Annotations: <none> |
| 247 | + |
| 248 | + Type: Opaque |
| 249 | + |
| 250 | + Data |
| 251 | + ==== |
| 252 | + publicApiKey: 31 bytes |
| 253 | + user: 22 bytes |
| 254 | + |
| 255 | +Next Steps |
| 256 | +---------- |
| 257 | + |
| 258 | +Now that you installed the |k8s-op-full|, created your |com| project and |
| 259 | +|k8s| |k8s-configmap|, and created your credentials, you are ready to |
| 260 | +deploy MongoDB resources. For more information on deploying MongoDB |
| 261 | +resources, see: |
| 262 | + |
| 263 | +- :doc:`/tutorial/deploy-standalone` |
| 264 | +- :doc:`/tutorial/deploy-replica-set` |
| 265 | +- :doc:`/tutorial/deploy-sharded-cluster` |
0 commit comments