Reputation: 1721
On the OpenShift Documentation for ConfigMaps (https://docs.openshift.com/enterprise/3.2/dev_guide/configmaps.html) is only an example of usage within Pods. But can I use ConfigMaps also inside DeploymentConfig?
The parameter declarations inside Pods look symilar to the DeploymentConfig.
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test-container
image: gcr.io/google_containers/busybox
command: [ "/bin/sh", "-c", "env" ]
env:
- name: SPECIAL_LEVEL_KEY
valueFrom:
configMapKeyRef:
name: special-config
key: special.how
- name: SPECIAL_TYPE_KEY
valueFrom:
configMapKeyRef:
name: special-config
key: special.type
restartPolicy: Never
Both use the env
property.
"spec": {
"containers": [
{
"env": [
{
"name": "PORT",
"value": "${MF-PORT}"
},
{
"name": "NODE_ENV",
"value": "${MF-ENVIRONMENT}"
}
],
Upvotes: 0
Views: 8042
Reputation: 58523
Yes, you can use ConfigMap
from a DeploymentConfig
.
If you already have a deployed application, you can add environment variables with them being set from a config map using the command:
oc set env dc/blog --from configmap/blog-settings
You can see how that translates into changes in the deployment config by instead running:
oc set env dc/blog --from configmap/blog-settings --dry-run -o json
For example, if the config map was originally created using:
oc create configmap blog-settings \
--from-literal BLOG_BANNER_COLOR=blue \
--from-literal BLOG_SITE_NAME="My Blog"
that would result in changes in the deployment config of:
"env": [
{
"name": "BLOG_BANNER_COLOR",
"valueFrom": {
"configMapKeyRef": {
"name": "blog-settings",
"key": "BLOG_BANNER_COLOR"
}
}
},
{
"name": "BLOG_SITE_NAME",
"valueFrom": {
"configMapKeyRef": {
"name": "blog-settings",
"key": "BLOG_SITE_NAME"
}
}
}
],
You can find a details on using config maps, and secrets, in the free eBook on OpenShift at:
Upvotes: 6