https://github.com/a1k0u/kustomize-nested-layout
Tool to support the layout of nested overlays in Kustomize
https://github.com/a1k0u/kustomize-nested-layout
kubernetes kustomize yaml
Last synced: about 2 months ago
JSON representation
Tool to support the layout of nested overlays in Kustomize
- Host: GitHub
- URL: https://github.com/a1k0u/kustomize-nested-layout
- Owner: a1k0u
- License: mit
- Created: 2025-06-17T11:12:12.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-19T21:11:51.000Z (about 1 year ago)
- Last Synced: 2025-06-19T22:23:36.594Z (about 1 year ago)
- Topics: kubernetes, kustomize, yaml
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kustomize Nested Layout
> Caution. Work in progress. Just proof of concept. Use at your own risk.
Kustomize does not support nested overlays out of the box, see [this](https://github.com/kubernetes-sigs/kustomize/issues/851) and [this](https://github.com/kubernetes-sigs/kustomize/issues/596#issuecomment-447167930) issues.
This tool (script) just convert nested layout to supported layout by Kustomize and run `kustomize build` command.
### Layout
Help to support layout with nested overlays without extra base directories.
```
kubernetes
├── development
│ ├── betas
│ │ └── kustomization.yaml
│ ├── testing
│ │ ├── deployment.yml
│ │ └── kustomization.yaml
│ ├── deployment.yml
│ ├── hpa_scaled_object.yml
│ └── kustomization.yaml
├── production
│ ├── cron-cluster
│ │ ├── us-east-2
│ │ │ ├── deployment.yml
│ │ │ └── kustomization.yaml
│ │ ├── deployment.yml
│ │ └── kustomization.yaml
│ ├── deployment.yml
│ ├── hpa_scaled_object.yml
│ └── kustomization.yaml
├── deployment.yml
├── hpa_scaled_object.yml
├── ingress.yml
├── service.yml
└── kustomization.yaml
```
Build `kubernetes/development/betas` with kustomize:
```
DIR=examples/kubernetes-nested-structure
go run main.go --root $DIR --build $DIR/development/betas
```
### Generation
Help to generate `resources` and `patches` fields in `kustomization.yaml` files if they are empty, or if no file exists, it will be created.
```
kubernetes
├── development
│ ├── betas
│ │ └── kustomization.yaml
│ ├── testing
│ │ ├── deployment.yml
│ │ └── kustomization.yaml
│ ├── deployment.yml
│ ├── hpa_scaled_object.yml
│ └── kustomization.yaml
├── production
│ ├── cron-cluster
│ │ ├── us-east-2
│ │ │ └── deployment.yml
│ │ └── deployment.yml
│ ├── deployment.yml
│ └── hpa_scaled_object.yml
├── deployment.yml
├── hpa_scaled_object.yml
├── ingress.yml
└── service.yml
```
If it is root kustomization, it will generate `resources` field with YAML files from the same directory.
Otherwise, it will be inherited from nearest parent kustomization.
If it is not root kustomization, it will generate `patches` field with YAML files from the same directory.
```
DIR=examples/kubernetes-no-kustomization-files
go run main.go --root $DIR \
--build $DIR/production/cluster-name/us-east-2 \
--generate-resources \
--generate-patches
```