1

I got APP whitch use config in yaml format Config is:

application:
    web-server:
      init-timeout: 2m
      shutdown-timeout: 1m
      sites-сonfig: ./app/sites/prod
kerberos:
  principal: APP_USER@DOMAIN.LOCAL
  keytab: /kerberos/keytab/test.keytab

I want to change settings of this config via Kustomize

Now I create in ./base catalog kustomization.yaml contains:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - deployment.yaml

configMapGenerator:
- name: config-app
  files:
  - config.yml

Next I create in ./base catalog config.yml contains my application config:

application:
    web-server:
      init-timeout: 2m
      shutdown-timeout: 1m
      sites-сonfig: ./app/sites/prod
kerberos:
  principal: APP_USER@DOMAIN.LOCAL
  keytab: /kerberos/keytab/test.keytab

And I create env catalog for my stage & test environment

for example catalog ./env/test contains kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base



patches:
- replica_count.yml

configMapGenerator:
  - name: config-app
    behavior: merge
    files:
      - config.yml
    options:
        disableNameSuffixHash: true      

File config.yml in directory ./env/test contains:

application:
kerberos:
  principal: TEST_USER@DOMAIN.LOCAL
  keytab: /kerberos/keytab/test_user.keytab

When I run kustomize build | kubectl apply --prune -f , I see this config-app in configMaps:

application:
    web-server:
      init-timeout: 2m
      shutdown-timeout: 1m
      sites-сonfig: ./app/sites/prod
kerberos:
  principal: APP_USER@DOMAIN.LOCAL
  keytab: /kerberos/keytab/test.keytab

How I can merge some settings from yaml in ./env/test to main config in ./base ? I don't want to duplicate full yaml config to ./env/test

Darkwind
  • 345
  • 9
  • 20

1 Answers1

1

The ConfigMapGenerator is not planned to support this type of merging functionality. He is overriding files with same names. Same user issue https://github.com/kubernetes-sigs/kustomize/issues/370. Its sad) I think to solve this problem you may use profiles:

config.yml common config
config-test.yml additional test env config.

And your application reading files in right order