cocreators-ee / project-template

Project template for kick-starting your work the right way
Other
5 stars 7 forks source link

[Feature request]: Merging kubernetes configs #3

Closed fbjorn closed 4 years ago

fbjorn commented 4 years ago

Imagine I have 4 different environments: test, demo , staging and production. If I have an application under app folder, and it results in such files:

Sometimes, only one key/value pair from those configs should be redefined per environment (e.g some URLs)

It would be nice to have a merging mechanism like: Base config content: (app/kube/01-config.yaml):

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  api_url: 'base.app.org'
  key: 'value'
  uwsgi_workers: '3'

Per-environment config content (e.g envs/demo/app/kube/01-config.yaml):

data:
  api_url: 'demo.app.org'

Instead of copy-pasting all the configuration data. It would be nice to see what exactly is redefined for environment, and it's also easier to maintain.

lietu commented 4 years ago

A few questions that we would need answered (even if the answer is "let's not worry about that now")

  1. How would you ensure that all variables that require overrides are overridden in all envs, e.g. if you have an API URL or public key or similar defined in the config, and you require it to be overridden for all envs - how can we determine if you've done it in all envs?

  2. How do you undefine things - this kind of merge should likely not just work on a flat ConfigMap, but any Deployment or other such more complicated structure as well, and in that case you might want to e.g. undefine some volume mounts, or other such configuration in an override? Maybe Kubernetes has some way to already explicitly define that e.g. various healthchecks are not wanted in some cases?

  3. How do you deal with multiple YAML documents per file? This is perfectly valid for Kubernetes and I would not want to limit the usage of Kubernetes configs with this tooling. Would we be ok with e.g.

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  api_url: 'base.app.org'

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config2
data:
  key: 'value'

to have an override such as

# app-config
---
# app-config2
data:
  key: "correct value"
lietu commented 4 years ago

From Kubernetes Slack discussion:

image

image

https://kubernetes.slack.com/archives/C09NXKJKA/p1572619469306400

lietu commented 4 years ago

It might also be none or ~

lietu commented 4 years ago

So I guess 2 & 3 are easy to answer right now - but 1 might require some thinking still

lietu commented 4 years ago

Everything except question 1 is solved with #5