user1047833
user1047833

Reputation: 343

How to provision environment specific application configuration with kubernetes

We are moving our ruby microservices to kubernetes and we used to hold environment specific configuration in the config/application.yml. With kubernetes, you can create environment specific files for each service, e.g. config/kubernetes/production.yml etc.

While kubernetes pod configuration file is able to hold environmental variables, it seems that you cannot really hold structured data in there.

For an example, in application.yml we have

development: &development
  process:
    notifier:
      type: 'terminal-notifier'
  ...

production: &production
  process:
    notifier:
      type: 'airbrake'
      api_key: 'xxxx'
      host: 'xxx.xxx.com'
  ...

Is it reasonable to continue this practice with kubernetes and break the environments up in the application.yml or does kubernetes have some other best practices for provisioning structured configuration for pod?

Note that until all services are migrated, we basically have to hold the configurations as such:

kubernetes_staging:
  <<: *staging
  ...

Upvotes: 2

Views: 807

Answers (1)

Christian Grabowski
Christian Grabowski

Reputation: 2882

You can do this a few ways, one is keep doing what you're doing in a single file, another is to use labels to specify which environment's config to use, and the other is use namespaces. I personally recommend namespaces, this way you can have separate .yml files for each environment that potentially spins up the same pods, but with different configurations, so to do this you would have staging, prod, etc namespaces. Namespaces also are a great way to have the same kubernetes cluster have a concept of staging and production. Additionally you can specify permissions for certain namespaces.

Here are the docs on namespaces https://github.com/kubernetes/kubernetes/blob/release-1.0/docs/design/namespaces.md

Upvotes: 1

Related Questions