mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
53 lines
2.0 KiB
Plaintext
53 lines
2.0 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * tutorials/dev-app-web-console.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="getting-started-web-console-creating-secret_{context}"]
|
|
= Providing access to the database by creating a secret
|
|
|
|
The `nationalparks` application needs information, such as the database name, username, and passwords, to access the MongoDB database. However, because this information is sensitive, you should not store it directly in the pod.
|
|
|
|
You can use a _secret_ to store sensitive information, and share that secret with workloads.
|
|
|
|
`Secret` objects provide a mechanism to hold sensitive information such as passwords, {product-title} client configuration files, and private source repository credentials. Secrets decouple sensitive content from the pods. You can mount secrets into containers by using a volume plugin or by passing the secret in as an environment variable. The system can then use secrets to provide the pod with the sensitive information.
|
|
|
|
The following procedure creates the `nationalparks-mongodb-parameters` secret and mounts it to the `nationalparks` workload.
|
|
|
|
.Prerequisites
|
|
|
|
* You have deployed the `nationalparks` back-end application.
|
|
* You have deployed the `mongodb-nationalparks` database application.
|
|
|
|
.Procedure
|
|
|
|
. Navigate to *Workloads* -> *Secrets*.
|
|
. Click *Create* -> *Key/value secret*.
|
|
. In the *Secret name* field, enter `nationalparks-mongodb-parameters`.
|
|
. Enter the following values for *Key* and *Value*:
|
|
+
|
|
.Secret keys and values
|
|
[cols="1,1"]
|
|
|===
|
|
|Key |Value
|
|
|
|
|`DATABASE_SERVICE_NAME`|`mongodb-nationalparks`
|
|
|`MONGODB_USER`|`mongodb`
|
|
|`MONGODB_PASSWORD`|`mongodb`
|
|
|`MONGODB_DATABASE`|`mongodb`
|
|
|`MONGODB_ADMIN_PASSWORD`|`mongodb`
|
|
|===
|
|
+
|
|
[TIP]
|
|
====
|
|
Click *Add key/value* to add each additional key/value pair.
|
|
====
|
|
|
|
. Click *Create*.
|
|
. Click *Add Secret to workload*.
|
|
. From the *Add this secret to workload* list, select `nationalparks`.
|
|
|
|
. Click *Save*.
|
|
|
|
This change in configuration triggers a new rollout of the `nationalparks` deployment with the environment variables properly injected.
|