0

I am working with an existing kustomization code base. The app heirarchy is:

└── application
    ├── base
    │   ├── kustomization.yaml
    │   └── deployment.yaml
    |   └── configmap.yaml
    └── overlays
        ├── nonprod
        └── prod

I have a need for a value in the configmap to be different based on geography also, say whether the prod/nonprod environment is in a US or EU. Do I need to change my overlay strategy to nonprod-us/nonprod-eu/prod-us/prod-eu and do a lot of duplication? Or is there a way I can nest or do a second override?

I thought maybe I could point to two overlays but I errored out with may not add resource with an already registered id: Deployment.v1.apps/reports but that could be because the way I attempted it was wrong.

glv
  • 994
  • 1
  • 1
  • 15
Adam Lang
  • 1
  • 1

1 Answers1

0

I understand your needs, but unfortunately it isn't possible to do a double patch on 2 levels on different paths.

You should: Org

move the patches/configurations to the last folder (in this example "eu").

Example:

cat overlays/kustomization.yaml

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

resources:
  - noprod

cat overlays/noprod/kustomization.yaml

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

resources:
  - eu

cat overlays/noprod/eu/kustomization.yaml

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

resources:
  - ../../../base

patches:
- target:
    kind: Deployment
    name: nginx-deployment
  patch: |-
    - op: replace
      path: /spec/template/metadata/labels/app
      value: nginx-noprod-eu

In my example I just changed the label.

Otherwise, if you want to completely review what you've done, you could try Kustomize's Components.

This is the doc:

https://kubectl.docs.kubernetes.io/guides/config_management/components/

Another useful link:

Kustomize: how to apply the same patch in multiple overlays without LoadRestrictionsNone

glv
  • 994
  • 1
  • 1
  • 15