mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
74 lines
3.2 KiB
Plaintext
74 lines
3.2 KiB
Plaintext
:_mod-docs-content-type: ASSEMBLY
|
|
[id="cloud-experts-deploying-configmaps-secrets-envvar"]
|
|
= Tutorial: ConfigMaps, secrets, and environment variables
|
|
include::_attributes/attributes-openshift-dedicated.adoc[]
|
|
:context: cloud-experts-deploying-configmaps-secrets-envvar
|
|
|
|
toc::[]
|
|
|
|
//rosaworkshop.io content metadata
|
|
//Brought into ROSA product docs 05-07-2024
|
|
|
|
This tutorial shows how to configure the OSToy application by using xref:../../nodes/pods/nodes-pods-configmaps.adoc[config maps], link:https://docs.openshift.com/container-platform/latest/cicd/builds/creating-build-inputs.html#builds-input-secrets-configmaps_creating-build-inputs[secrets], and link:https://docs.openshift.com/container-platform/3.11/dev_guide/environment_variables.html[environment variables]. For more information, see these linked topics.
|
|
|
|
== Configuration using ConfigMaps
|
|
Config maps allow you to decouple configuration artifacts from container image content to keep containerized applications portable.
|
|
|
|
.Procedure
|
|
* In the OSToy app, in the left menu, click *Config Maps*, displaying the contents of the config map available to the OSToy application. The code snippet shows an example of a config map configuration:
|
|
+
|
|
.Example output
|
|
[source,text]
|
|
----
|
|
kind: ConfigMap
|
|
apiVersion: v1
|
|
metadata:
|
|
name: ostoy-configmap-files
|
|
data:
|
|
config.json: '{ "default": "123" }'
|
|
----
|
|
|
|
== Configuration using secrets
|
|
Kubernetes `Secret` objects allow you to store and manage sensitive information, such as passwords, OAuth tokens, and SSH keys. Putting this information in a secret is safer and more flexible than putting it in plain text into a pod definition or a container image.
|
|
|
|
.Procedure
|
|
|
|
* In the OSToy app, in the left menu, click *Secrets*, displaying the contents of the secrets available to the OSToy application. The code snippet shows an example of a secret configuration:
|
|
+
|
|
.Example output
|
|
[source,text]
|
|
----
|
|
USERNAME=my_user
|
|
PASSWORD=VVNFUk5BTUU9bXlfdXNlcgpQQVNTV09SRD1AT3RCbCVYQXAhIzYzMlk1RndDQE1UUWsKU01UUD1sb2NhbGhvc3QKU01UUF9QT1JUPTI1
|
|
SMTP=localhost
|
|
SMTP_PORT=25
|
|
----
|
|
|
|
== Configuration using environment variables
|
|
Using environment variables is an easy way to change application behavior without requiring code changes. It allows different deployments of the same application to potentially behave differently based on the environment variables. {product-title} makes it simple to set, view, and update environment variables for pods or deployments.
|
|
|
|
.Procedure
|
|
|
|
* In the OSToy app, in the left menu, click *ENV Variables*, displaying the environment variables available to the OSToy application. The code snippet shows an example of an environmental variable configuration:
|
|
+
|
|
.Example output
|
|
[source,text]
|
|
----
|
|
{
|
|
"npm_config_local_prefix": "/opt/app-root/src",
|
|
"STI_SCRIPTS_PATH": "/usr/libexec/s2i",
|
|
"npm_package_version": "1.7.0",
|
|
"APP_ROOT": "/opt/app-root",
|
|
"NPM_CONFIG_PREFIX": "/opt/app-root/src/.npm-global",
|
|
"OSTOY_MICROSERVICE_PORT_8080_TCP_PORT": "8080",
|
|
"NODE": "/usr/bin/node",
|
|
"LD_PRELOAD": "libnss_wrapper.so",
|
|
"KUBERNETES_SERVICE_HOST": "172.30.0.1",
|
|
"OSTOY_MICROSERVICE_PORT": "tcp://172.30.60.255:8080",
|
|
"OSTOY_PORT": "tcp://172.30.152.25:8080",
|
|
"npm_package_name": "ostoy",
|
|
"OSTOY_SERVICE_PORT_8080_TCP": "8080",
|
|
"_": "/usr/bin/node"
|
|
"ENV_TOY_CONFIGMAP": "ostoy-configmap -env"
|
|
}
|
|
---- |