Kustomize: Multi-layer overlays fail to render

Created on 5 Dec 2018  ยท  4Comments  ยท  Source: kubernetes-sigs/kustomize

I have a project that uses 4 layers, each of which uses the previous layer as its base.

overlays/sandbox3.us-east-1

bases:
- ../aws-nonprod

overlays/aws-nonprod

bases:
- ../aws

overlays/aws

bases:
- ../../base

When I run kustomize build overlays/sandbox3.us-east-1 with v1.0.11 I get

Error: loadResMapFromBasesAndResources: SemiResources: loadResMapFromBasesAndResources: couldn't make ldr for ../aws: cycle detected: new root '/Users/mgoodness/dev/cluster-configuration/networkpolicy/overlays/aws' contains previous root '/Users/mgoodness/dev/cluster-configuration/networkpolicy/overlays/aws-nonprod'

This configuration worked with kustomize v1.0.10. I am able to render if I skip an intermediate layer. Other projects that use only 3 layers also render correctly.

Most helpful comment

@mgoodness feel free to review #624

@bstevenson As things now stand, the layout you describe is disallowed. We found that allowing an overlay to be a subdirectory of a base makes it too easy to create recursion problems.

The fix is to change from

โ”œโ”€โ”€ kustomization.yaml
โ””โ”€โ”€ overlays
    โ””โ”€โ”€ na3
        โ””โ”€โ”€ dev
            โ””โ”€โ”€ kustomization.yaml

to

โ”œโ”€โ”€ base
โ”‚ย ย  โ””โ”€โ”€ kustomization.yaml
โ””โ”€โ”€ overlays
    โ””โ”€โ”€ na3
        โ””โ”€โ”€ dev
            โ””โ”€โ”€ kustomization.yaml  #  contains "bases: ../../../base"

FWIW, the top level app dir is a good place for a README.md.

All 4 comments

My team has run into the same with our Skaffold setup.

lemme look

Seeing same issue or very similar issue. Worked in 1.0.10 (only changed the disableHash ---> disableNameSuffixHash between 1.0.10 --> 1.0.11)

Structure:

app/
โ”œโ”€โ”€ app.yaml
โ”œโ”€โ”€ config-map.yaml
โ”œโ”€โ”€ kustomization.yaml
โ”œโ”€โ”€ overlays
โ”‚ย ย  โ””โ”€โ”€ na3
โ”‚ย ย      โ””โ”€โ”€ dev
โ”‚ย ย          โ””โ”€โ”€ kustomization.yaml
โ””โ”€โ”€ secrets.yaml

Base kustomization file:

cat app/kustomization.yaml
namespace: "test"
resources:
- config-map.yaml
- app.yaml
- secrets.yaml
generatorOptions:
  timeoutSeconds: 20
  disableNameSuffixHash: true

Overlay kustomization file:

cat app/overlays/na3/dev/kustomization.yaml
bases:
- ../../../../app
imageTags:
- name: <private_repo>/app
  newTag: 6.5.0
Error: loadResMapFromBasesAndResources: couldn't make ldr for ../../../../app: cycle detected: new root '/Users/xxxxxxx/repos/xxxxxx/kubernetes/base/app' contains previous root '/Users/xxxxxxxx/repos/xxxxxxxxxx/kubernetes/base/app/overlays/na3/dev'

@mgoodness feel free to review #624

@bstevenson As things now stand, the layout you describe is disallowed. We found that allowing an overlay to be a subdirectory of a base makes it too easy to create recursion problems.

The fix is to change from

โ”œโ”€โ”€ kustomization.yaml
โ””โ”€โ”€ overlays
    โ””โ”€โ”€ na3
        โ””โ”€โ”€ dev
            โ””โ”€โ”€ kustomization.yaml

to

โ”œโ”€โ”€ base
โ”‚ย ย  โ””โ”€โ”€ kustomization.yaml
โ””โ”€โ”€ overlays
    โ””โ”€โ”€ na3
        โ””โ”€โ”€ dev
            โ””โ”€โ”€ kustomization.yaml  #  contains "bases: ../../../base"

FWIW, the top level app dir is a good place for a README.md.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nabadger picture nabadger  ยท  4Comments

natasha41575 picture natasha41575  ยท  3Comments

wuestkamp picture wuestkamp  ยท  3Comments

yujunz picture yujunz  ยท  5Comments

laupow picture laupow  ยท  4Comments