1
+ stepnum : 1
2
+ level : 4
3
+ ref : vault-add-policies
4
+ title : " Add the |vault-short| policies for the |k8s-op-short| and its components."
5
+ content : |
6
+
7
+ Write the policies for |k8s-op-short|, MongoDB database, |onprem|, and AppDB resources
8
+ to |vault-short| using the following command, replacing 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
+ * - {PolicyName}
18
+ - Human-readable label that identifies the policy you're creating in |vault-short|.
19
+
20
+ * - {PathToPolicyFile}
21
+ - The absolute path to the policy file you downloaded.
22
+
23
+ .. code-block:: sh
24
+
25
+ vault policy write {PolicyName} {PathToPolicyFile}
26
+
27
+ Repeat the command for all the resources you're adding to |vault-short|.
28
+
29
+ ---
30
+
31
+ stepnum : 2
32
+ level : 4
33
+ ref : vault-add-roles
34
+ title : " Bind the |vault-short| roles to the |vault-short| policies for the |k8s-op-short| and its components."
35
+ content : |
36
+
37
+ Bind |vault-short| roles to the policies for |k8s-op-short|, MongoDB database,
38
+ |onprem|, and AppDB resources using the following four commands, replacing the
39
+ variables with the values in the table:
40
+
41
+ .. list-table::
42
+ :widths: 30 70
43
+ :header-rows: 1
44
+
45
+ * - Placeholder
46
+ - Description
47
+
48
+ * - {OperatorPolicyName}
49
+ - A human-readable label that identifies the |k8s-op-short| policy in |vault-short|.
50
+
51
+ * - {DatabasePolicyName}
52
+ - A human-readable label that identifies the MongoDB database policy in |vault-short|.
53
+
54
+ * - {OpsManagerPolicyName}
55
+ - A human-readable label that identifies the |onprem| policy in |vault-short|.
56
+
57
+ * - {AppDBPolicyName}
58
+ - A human-readable label that identifies the AppDB policy in |vault-short|.
59
+
60
+ * - {ServiceAccountNamespace}
61
+ - Label that identifies the namespace for the service account bound to your pod.
62
+
63
+ .. code-block:: sh
64
+
65
+ vault write auth/kubernetes/role/{OperatorPolicyName}
66
+ bound_service_account_names=enterprise-operator bound_service_account_namespaces={ServiceAccountNamespace}
67
+
68
+ .. code-block:: sh
69
+
70
+ vault write auth/kubernetes/role/{DatabasePolicyName}
71
+ bound_service_account_names=mongodb-enterprise-database-pods bound_service_account_namespaces={ServiceAccountNamespace}
72
+
73
+ .. code-block:: sh
74
+
75
+ vault write auth/kubernetes/role/{OpsManagerPolicyName}
76
+ bound_service_account_names=mongodb-enterprise-ops-manager bound_service_account_namespaces={ServiceAccountNamespace}
77
+
78
+ .. code-block:: sh
79
+
80
+ vault write auth/kubernetes/role/{AppDBPolicyName}
81
+ bound_service_account_names=mongodb-enterprise-appdb bound_service_account_namespaces={ServiceAccountNamespace}
82
+
83
+ These commands ensure that each component's pods have only the access specified in their
84
+ policy.
85
+
86
+ .. note::
87
+
88
+ This step grants the |k8s-op-short| access to
89
+ |vault-short|. To use |vault-short| with applications that the
90
+ |k8s-op-short| doesn't manage, you must write and bind |vault-short| policies for those
91
+ applications.
92
+
93
+ You can adapt the commands in this step to bind other policies by
94
+ replacing the name of the |k8s-service-accounts|. To configure other
95
+ applications to use |vault-short|, replace the
96
+ {ServiceAccountName} in the following command with the service account used
97
+ for the application's pod:
98
+
99
+ .. code-block:: sh
100
+
101
+ vault write auth/kubernetes/role/{PolicyName}
102
+ bound_service_account_names={ServiceAccountName} bound_service_account_namespaces={ServiceAccountNamespace}
103
+
104
+
105
+ ---
106
+ stepnum : 3
107
+ level : 4
108
+ ref : vault-add-annotations
109
+ title : " Add the annotations to the |k8s| deployment file."
110
+ content : |
111
+
112
+ Add the following highlighted lines to the ``spec.template.metadata.annotations`` section of your
113
+ |k8s-op-short| deployment file. For most users, this file's name is ``mongodb-enterprise.yaml`` or
114
+ ``mongodb-enterprise-openshift.yaml``.
115
+
116
+ .. note::
117
+
118
+ If you installed the |k8s-op-short| using Helm, the |k8s-op-short| already
119
+ added these annotations. You can proceed to the next step.
120
+
121
+ .. code-block:: sh
122
+ :emphasize-lines: 11-12
123
+
124
+ apiVersion: apps/v1
125
+ kind: Deployment
126
+ metadata:
127
+ name: mongodb-enterprise-operator
128
+ namespace: production
129
+ spec:
130
+ replicas: 1
131
+ template:
132
+ metadata:
133
+ annotations:
134
+ vault.hashicorp.com/agent-inject: "true"
135
+ vault.hashicorp.com/role: "mongodbenterprise"
136
+
137
+ If you're running |vault-short| in |tls| mode, you must also add the following
138
+ highlighted line to the file, replacing {TLSSecret} with the name of the secret
139
+ containing a ``ca.crt`` entry. The content of the ``ca.crt`` entry must match
140
+ the certificate of the |certauth| used to generate the |vault-short| TLS certificates.
141
+
142
+ .. code-block:: sh
143
+ :emphasize-lines: 4-5
144
+
145
+ annotations:
146
+ vault.hashicorp.com/agent-inject: "true"
147
+ vault.hashicorp.com/role: "mongodbenterprise"
148
+ vault.hashicorp.com/tls-secret: {TLSSecret}
149
+ vault.hashicorp.com/ca-cert: /vault/tls/ca.crt
150
+
151
+ ---
152
+ stepnum : 4
153
+ level : 4
154
+ ref : vault-define-environment-variable
155
+ title : " Define the environment variable in |k8s|."
156
+ content : |
157
+
158
+ Add the following highlighted lines to the ``spec.env`` section of your
159
+ |k8s-op-short| deployment file. For most users, this file's name is ``mongodb-enterprise.yaml`` or
160
+ ``mongodb-enterprise-openshift.yaml``.
161
+
162
+ .. code-block:: sh
163
+ :emphasize-lines: 10-11
164
+
165
+ apiVersion: apps/v1
166
+ kind: Deployment
167
+ metadata:
168
+ name: mongodb-enterprise-operator
169
+ namespace: production
170
+ spec:
171
+ env:
172
+ - name: OPERATOR_ENV
173
+ value: ENVIRONMENT_NAME
174
+ - name: SECRET_BACKEND
175
+ value: VAULT_BACKEND
176
+
177
+ This `defines the environment variable <https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/>`__
178
+ for |vault-short| in |k8s|.
179
+ ---
180
+ stepnum : 5
181
+ level : 4
182
+ ref : vault-create-file
183
+ title : " Create a file with the |vault-short| configuration information."
184
+ content : |
185
+
186
+ Using your preferred text editing application, create a file named ``config``.
187
+ Paste the following text into the file:
188
+
189
+ .. code-block:: sh
190
+
191
+ apiVersion: v1
192
+ kind: ConfigMap
193
+ metadata:
194
+ name: secret-configuration
195
+ namespace: {Namespace}
196
+ data:
197
+ VAULT_SERVER_ADDRESS: {VaultServerAddress}
198
+ OPERATOR_SECRET_BASE_PATH: mongodbenterprise/operator
199
+ DATABASE_SECRET_BASE_PATH: mongodbenterprise/database
200
+ OPS_MANAGER_SECRET_BASE_PATH: mongodbenterprise/opsmanager
201
+ APPDB_SECRET_BASE_PATH: mongodbenterprise/appdb
202
+
203
+ The paths in this file are the default paths. You can replace them with your
204
+ base paths if you customized your |k8s-op-short| configuration.
205
+
206
+ If you're running |vault-short| in |tls| mode, you must also add the following
207
+ highlighted line to the file:
208
+
209
+ .. code-block:: sh
210
+ :emphasize-lines: 3
211
+
212
+ OPS_MANAGER_SECRET_BASE_PATH: mongodbenterprise/opsmanager
213
+ APPDB_SECRET_BASE_PATH: mongodbenterprise/appdb
214
+ TLS_SECRET_REF: {TLSSecret}
215
+
216
+ ---
217
+ stepnum : 6
218
+ level : 4
219
+ ref : vault-update-file-placeholders
220
+ title : " Replace the placeholders in the |vault-short| configuration information."
221
+ content : |
222
+
223
+ Replace the placeholders in the ``config`` file with these values. Save
224
+ the file with a |yaml| file type by replacing the ``.txt`` file extension with
225
+ ``.yaml``.
226
+
227
+ .. list-table::
228
+ :widths: 30 70
229
+ :header-rows: 1
230
+
231
+ * - Placeholder
232
+ - Description
233
+
234
+ * - {Namespace}
235
+ - The :ref:`namespace you created <k8s-prerequisites>`
236
+ for the |k8s-op-short|. The default namespace is ``mongodb``.
237
+
238
+ * - {VaultServerAddress}
239
+ - The address that the |k8s-op-short| should use to connect to
240
+ |vault-short|.
241
+
242
+ * - {TLSSecret}
243
+ - Name of a secret containing a ``ca.crt`` entry. The content of the
244
+ ``ca.crt`` entry must match the certificate of the |certauth| used to generate
245
+ the |vault-short| TLS certificates.
246
+
247
+ ---
248
+ stepnum : 7
249
+ level : 4
250
+ ref : vault-create-configmap
251
+ title : " Create a ConfigMap with the |vault-short| configuration."
252
+ content : |
253
+
254
+ Issue the following command to create a |k8s-configmap| containing the |vault-short| information:
255
+
256
+ .. code-block:: sh
257
+
258
+ kubectl create configmap secret-configuration --from-file=config.yaml
259
+
260
+ This creates a |k8s-configmap| named ``secret-configuration``. This
261
+ |k8s-configmap| contains the contents of the ``config`` file.
262
+
263
+ ---
264
+ stepnum : 8
265
+ level : 4
266
+ ref : vault-manually-migrate-secrets
267
+ title : " Manually migrate secrets that don't migrate automatically"
268
+ content : |
269
+
270
+ You must manually migrate the following secrets to store them in |vault-short|:
271
+
272
+ - Any existing user-created secrets, including :ref:`Operator credentials stored as Kubernetes secrets <create-k8s-secret>`,
273
+ if applicable
274
+ - :ref:`The gen-key secret <om-rsrc-considerations-encrypt-key>`
275
+ |k8s-op-short| creates
276
+ - The |onprem| :ref:`admin credentials/admin key <om-arch-steps>`
277
+ |k8s-op-short| creates
278
+ - TLS secrets
279
+
280
+ To manually migrate secrets, `add them to Vault <https://www.vaultproject.io/docs/secrets/kv/kv-v2#usage>`__.
281
+ After you add them to |vault-short|, you can remove them from |k8s|.
282
+
283
+ All other secrets migrate automatically, and |k8s-op-short| uses
284
+ |vault-short| for new secrets.
285
+
286
+ .. note::
287
+
288
+ cert-manager automatically recreates the |k8s| |k8s-secrets| that
289
+ it generates if you delete them from |k8s|. You must manually manage the
290
+ removal of these secrets or stop using cert-manager to avoid storing
291
+ the secrets in |k8s|.
292
+ ...
0 commit comments