Testing Kustomization rendering before pushing changes

This got me so many times… making some changes to the manifests and pushing them without a worry only to then see error when checking the Kustomization status!

Anyway, the “kubectl” client can render any Kustomization and alert you of any YAML shenanigans or if any dependencies are missing in advance. In a repo directory with this structure:

.
├── base
│   ├── dashboards
│   │   ├── cluster.json
│   │   └── control-plane.json
│   ├── kustomization.yaml
│   └── podmonitor.yaml
├── dev
│   └── kustomization.yaml
└── prod
    └── kustomization.yaml

, you can run from the root of the directory:

kubectl kustomize ./prod

#  Or

kubectl kustomize ./dev

Which will render the manifests to stdout. In my case, the “base/dashboards” directory was misspelled (it was “dashboard”) which led to the FluxCD Kustomization failing.

Ideally these changes would go via a feature branch and they’d be validated in CICD, but for now this will do.