DSL Merge Behavior

Generally, the merge should behave as expected. For example, map or Hash fields are merged together from multiple layers. Strings are simply replaced.

Hash Example

.kubes/resources/base/all.rb

labels(app: "demo")
# ...

.kubes/resources/base/all/env.rb

labels(env: Kubes.env)
# ...

.kubes/resources/web/deployment.rb

labels(role: "web")
# ...

Layering results in:

.kubes/output/web/deployment.yaml

metadata:
  labels:
    app: demo
    env: dev
    role: web
# ...

Hash Merge Behavior Override

You can override the merge behavior with the _mode key.

.kubes/resources/web/deployment.rb

labels(role: "web", _mode: "reset")
# ...

This will completely reset the labels and result in:

metadata:
  labels:
    role: web
# ...

String Example

The merging of simple String is a straightforward replacement.

.kubes/resources/web/deployment.rb

image docker_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
# ...

.kubes/resources/web/deployment/prod.rb

image "nginx:prod-v1"
# ...

Results in:

.kubes/output/web/deployment.yaml

spec:
  # ...
  template:
    spec:
      containers:
      - image: nginx:prod-v1
        name: demo-web
  # ...

For a full list of the available methods, refer to the source itself syntax/backend_config.rb.