Managing Environment Variables (Env Vars) - ocd-scm/ocd-meta GitHub Wiki

With 12 factor apps we store environment variables in the environment. OCD lets you manage them through git and deploy them using helm charts run on a webhook.

There are actually three types of env vars

  • “Regular env vars”. With OCD we store them as yaml in git and deploy them using the ocd-configmap helm chart. This loads them into a named k8s ConfigMap. Many ConfigMaps can then be referenced by the ocd-deployer to mount as multiple sets of env vars in the deployed k8s pods.
  • “Secret env vars”. With OCD we store them as encrypted yaml in git and deploy them using the ocd-secret helm chart. This loads them into a named k8s Secret. They can then be referenced by the ocd-deployer to mount them as multiple sets of env vars in the deployed k8s pods.
  • “Static env vars” that don’t vary by openshift project (kubernetes namespace). These are rare. An example might be flags that configure library code to be able to run within your container runtime. The recommendation is to “bake these” into the image. With s2i you can overload the run script in your app code git repo to export these env vars then call the default run script at $STI_SCRIPTS_PATH e.g. create an .s2i/bin/run script:
#!/bin/bash
export SOME_STATIC_ENV_VAR=whatever
exec /usr/libexec/s2i/run