Skip to content

Commit 0d29e97

Browse files
sarahsimpersjwilliams-mongo
authored andcommitted
(DOCSP-19963) Adds the option for HELM to get connection string from automatically-created K8s secret (#798)
* (DOCSP-19963) Adds the option for HEML to get connection string from automatically-created K8s secret * Adds steps file for connecting with secret * Changes secret name info * Includes changes from tech review * Adds changes from copy review * Fixes build error
1 parent b35d154 commit 0d29e97

6 files changed

+123
-8
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
When you create a new MongoDB database user, |k8s-op-short| automatically
2+
creates a new |k8s| |k8s-secret|. The |k8s| |k8s-secret|
3+
contains the following information about the new database user:
4+
5+
- ``username``: Username for the database user
6+
- ``password``: Password for the database user
7+
- ``connectionString.standard``: :manual:`Standard connection string </reference/connection-string/#std-label-connections-standard-connection-string-format>`
8+
that can connect you to the database as this database user.
9+
- ``connectionString.standardSrv``: :manual:`DNS seed list connection string </reference/connection-string/#dns-seed-list-connection-format>` that can
10+
connect you to the database as this database user.

source/includes/steps-add-database-user-scram.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ content: |
101101
.. code-block:: sh
102102
103103
kubectl apply -f <database-user-conf>.yaml
104+
105+
.. note::
106+
107+
.. include:: /includes/facts/fact-if-create-user-creates-secret.rst
108+
109+
You can use these credentials to :ref:`Connect to a MongoDB Database Resource from Inside Kubernetes <connect-from-inside-k8s>`.
104110
---
105111
title: "View the newly created user in |com|."
106112
level: 4

source/includes/steps-add-database-user.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ content: |
137137
.. code-block:: sh
138138
139139
kubectl apply -f <database-user-conf>.yaml
140+
141+
.. note::
142+
143+
.. include:: /includes/facts/fact-if-create-user-creates-secret.rst
144+
145+
You can use these credentials to :ref:`Connect to a MongoDB Database Resource from Inside Kubernetes <connect-from-inside-k8s>`.
140146
---
141147
title: "View the newly created user in |com|."
142148
level: 4
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: "Run the command to view the Kubernetes secret file."
3+
level: 4
4+
stepnum: 1
5+
ref: retrieve-connection-string
6+
content: |
7+
Run the following command in a terminal to view the |k8s-secret|, replacing
8+
the variables with the values in the table:
9+
10+
.. list-table::
11+
:widths: 30 70
12+
:header-rows: 1
13+
14+
* - Placeholder
15+
- Description
16+
17+
* - {MongoDB-Resource-Name}
18+
- Human-readable label that identifies the MongoDB resource.
19+
20+
* - {User-Name}
21+
- Human-readable label that identifies the MongoDB user.
22+
23+
.. code-block:: none
24+
:copyable: true
25+
26+
kubectl get secret {MongoDB-Resource-Name}-{User-Name}-admin -o jsonpath='{.data}'
27+
28+
If this command returns an error, you can verify the name of the |k8s-secret| by
29+
running the following command and retrieving the correct name:
30+
31+
.. code-block:: none
32+
:copyable: true
33+
34+
kubectl get secrets
35+
---
36+
title: "Copy the ``connectionString.standard`` value displayed in the Kubernetes secret file."
37+
level: 4
38+
stepnum: 2
39+
ref: copy-command-secret-file
40+
---
41+
title: "Run the connection command."
42+
level: 4
43+
stepnum: 3
44+
ref: run-command
45+
content: |
46+
47+
Use the ``connectionString.standard`` value within a :manual:`connection string </reference/connection-string/#standard-connection-string-format>`
48+
to connect to the deployment.
49+
50+
.. code-block:: none
51+
:copyable: true
52+
53+
mongosh {connectionString.standard}
54+
55+
---
56+
title: "(Optional) Mount the Kubernetes secret in your pod."
57+
level: 4
58+
stepnum: 4
59+
ref: mount-k8s-secret-to-connect
60+
content: |
61+
62+
You can :k8sdocs:`mount the secret in your pod </concepts/configuration/secret/#using-secrets-as-files-from-a-pod>`
63+
to ensure that your applications can access the credentials.
64+
65+
...
66+
67+

source/tutorial/connect-from-inside-k8s.txt

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,40 @@ You must be able to connect to the host and port where you deployed your
1919
Procedure
2020
---------
2121

22-
Perform the following steps in the |mms| or
23-
`Cloud Manager <docs.cloudmanager.com/current/>`__
24-
application, depending on where your clusters are hosted:
22+
Retrieve and run the connection command for your deployment. You can retrieve
23+
the connection command from the |mms| or
24+
:cloudmgr:`Cloud Manager </>`
25+
application, depending on where your clusters are hosted. You can also retrieve the connection command from
26+
the |k8s| |k8s-secret| that the |k8s-op-short| creates automatically when you
27+
:ref:`add a MongoDB user with SCRAM authentication <create-db-user-scram>` or X509.
2528

26-
.. include:: /includes/steps/connect-from-inside-k8s.rst
29+
The install procedure varies based on how you want to retrieve your connection string:
2730

28-
When connecting to a resource from inside of |k8s|, the
29-
hostname to which you connect has the following form:
31+
.. tabs::
3032

31-
.. code-block:: sh
33+
.. tab:: Using the Application
34+
:tabid: UsingTheApplication
35+
36+
Perform the following steps in the |mms| or :cloudmgr:`Cloud Manager </>`
37+
application, depending on where your clusters are hosted:
38+
39+
.. include:: /includes/steps/connect-from-inside-k8s.rst
40+
41+
When connecting to a resource from inside of |k8s|, the
42+
hostname to which you connect has the following form:
43+
44+
.. code-block:: sh
45+
46+
<k8s-pod-name>.<k8s-internal-service-name>.<k8s-namespace>.<cluster-name>
47+
48+
.. tab:: Using the Kubernetes Secret
49+
:tabid: UsingK8sSecret
50+
51+
.. include:: /includes/facts/fact-if-create-user-creates-secret.rst
52+
53+
Perform the following steps to view the credentials and
54+
use the connection string to connect to MongoDB:
55+
56+
.. include:: /includes/steps/connect-from-inside-k8s-using-secret.rst
3257

33-
<k8s-pod-name>.<k8s-internal-service-name>.<k8s-namespace>.<cluster-name>
3458

source/tutorial/manage-database-users-scram.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ Create User Secret
9090

9191
.. include:: /includes/steps/add-database-user-secret-scram.rst
9292

93+
.. _create-db-user-scram:
94+
9395
Create MongoDBUser
9496
~~~~~~~~~~~~~~~~~~
9597

0 commit comments

Comments
 (0)