4

I have a resource yaml file in a folder structure given below

base

---- first.yaml

main

---- kustomization.yaml

In kustomization.yaml I am referring the first.yaml as

resources:

  • ../base/first.yaml

But I am getting an error when i do apply of kubectl apply -f kustomizatio.yaml

accumulating resources: accumulating resources from '../base/first.yaml': security; file '../base/first.yaml' is not in or below '../base'

How can i call the first.yaml resource from the folder base to the kustomization in main folder?

Kabilan R
  • 43
  • 1
  • 1
  • 3

2 Answers2

12

Kustomize cannot refer to individual resources in parent directories, it can only refer to resources in current or child directories, but it can refer to other Kustomize directories.

The following would be a valid configuration for what you have:

.
├── base
│   ├── main
│   │   ├── kustomization.yaml
│   │   └── resource.yaml
│   └── stuff
│       ├── first.yaml
│       └── kustomization.yaml
└── cluster
    └── kustomization.yaml

Contents of base/main/kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - resource.yaml

Contents of base/stuff/kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - first.yaml

Contents of cluster/kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
 - ../base/main
 - ../base/stuff
Highway of Life
  • 22,803
  • 16
  • 52
  • 80
0

Run kustomize build from one folder down, kustomize build ./main. You aren't allowed to .. up past where kustomize started from, just to be safe.

coderanger
  • 52,400
  • 4
  • 52
  • 75