I have 2 kustomization overlays that call the same configuration. I need to have two kustomization.yaml files in the same folder

Viewed 1653
overlays -----> configuration1 ----> kustomization.yaml 
         |   
         |----> configuration2 ----> kustomization.yaml


resources ------> kustomization.yaml

# in file resources/kustomization.yaml
# for configuration1 
resources:
  - pvc.yaml
  - deployment.yaml
  - namespace.yaml

# for configuration2
resources:
  - pvc.yaml
  - network.yaml
  - istio.yaml

end goal

kubectl apply -k overlays/configuration1
kubectl apply -k overlays/configuration2

I have an overlays folder that contains two folders. configuration1 and configuration2. In those folders I have a kustomization.yaml file. These two kustomization files call the same resource folder. configuration1 and configuration2 need to have a different list of resources specified. Can I create two different kustomize.yaml files in the resource folder or is there anyway to specify two different list of resources in the same kustomization.yaml?

1 Answers

In this case it would use the following structure:

base/
  kustomization.yaml
  pvc.yaml
overlays/
  configuration1/
    kustomization.yaml
    deployment.yaml
    namespace.yaml
  configuration2/
    kustomization.yaml
    network.yaml
    istio.yaml

base/kustomization.yaml:

resources:
  - pvc.yaml

overlays/configuration1/kustomization.yaml:

resources:
  - ../../base
  - namespace.yaml
  - deployment.yaml

overlays/configuration2/kustomization.yaml:

resources:
  - ../../base
  - network.yaml
  - istio.yaml

The idea is to keep in the base the configuration that is common to both and move to each overlay the configuration specific to it.

Related