- Log into OpenShift. Click the cog in the top right corner of the console. Copy the oc login command and paste it into a command window on your local machine.
- Once signed in, create the new configMap and set a new name value pair with:
oc create configmap greeter-props --from-literal greeter.prefix=Bonjour
- List the new configMap with:
oc get configmap/greeter-props -o json
{
"apiVersion": "v1",
"data": {
"greeter.prefix": "Bonjour"
},
"kind": "ConfigMap",
"metadata": {
"creationTimestamp": "2019-03-29T22:54:05Z",
"name": "greeter-props",
"namespace": "ag-devops-lab-deploy",
"resourceVersion": "716868495",
"selfLink": "/api/v1/namespaces/ag-devops-lab-deploy/configmaps/greeter-props",
"uid": "8e078e41-5275-11e9-9c9b-0050568348cc"
}
}
- When a config map is created, it is not associated with any application. To pass the settings in this config map as environment variables in a deployment configuration, you need to run the extra step of:
oc set env dc/greeterapp --from configmap/greeter-props
- Redeply the application to pick up the new property. Test with
https://openshift-endpoint/greet/myName
Result should show:
Bonjour Shaun, blah blah... (Note the Bonjour word was picked from the property in the configMap)
http://v1.uncontained.io/playbooks/app_dev/properties-management.html#using-environment-variables