4

I am gonna deploy a node js service in openshift and there are few properties such as database configs and app properties which I need to externalize.

I have java applications running as part of solution which uses config server as config store and GIT as source. I have seen libs for npm to integrate with spring config server.

So, I am looking for best practices here, what would be best approach for externalizing configs in nodejs in orchestration tools like k8s or openshift. Or can we go with config server int the above scenario?

Please let know of any info , any pointers are highly appreciated.

Ganesh Shenoy
  • 619
  • 1
  • 10
  • 28

3 Answers3

5

There are multiple possibilities, one being the Cloud Config Server as you noted. However, the naive approach according to the Twelve-Factor App, the config should be stored in the environment:

The twelve-factor app stores config in environment variables

In OpenShift / Kubernetes, this means that we will store the configuration in the Deployment itself, in ConfigMaps or Secrets and then use these with envFrom.configMapRef (here is an example).

Simon
  • 4,251
  • 2
  • 24
  • 34
3

If you are moving towards orchestration tools, I would say use their offering. In k8s, you would typically use ConfigMaps to manage your application configs. The beauty of this solution is that you can also do Configuration as Code, so you keep your Configmaps version-controlled.

One more thing, NodeJs best practices is to use environment variables. So you can use orchestration offering to mount all your configs to the environment, plus you get secrets encryption for your sensitive info (API keys, etc..)

obanby
  • 106
  • 1
  • 7
2

For anyone if it would help, we went for environment variable approach since we had very minimal parameters to work with and we don't see much change in this approach. If it grows we would be looking at the configmap approach (as also suggested by simon / obanby) above.

Ganesh Shenoy
  • 619
  • 1
  • 10
  • 28