Closed bozho closed 3 weeks ago
You can’t have a kustomization.yaml in the cluster dir, this would make Flux uninstall itself. The issue you are getting is from the fact that you have 2 Kustomizations fighting each other, rename the one under clusters to apps. See here an example of how to structure your repo: https://github.com/fluxcd/flux2-kustomize-helm-example
Hi,
I'm not sure I understand... I haven't seen Flux trying to uninstall itself or any of the components with my repo structure, only the podinfo
resources (depending on prune
values).
I've tried renaming the "parent" kustomization.yaml
to apps.yaml
and observed the same behaviour (I did have to add metadata.name
to the file after renaming it - flux was complaining about it missing).
I've set up a minimal repo that replicates the issue I'm seeing.
I stumbled upon this problem while reading this blog about organising k8s/flux repos for scale, with reusable components. This is their example repo, and all their cluster instances have kustomization.yaml
files inside <cluster>/platform
directory, alongside flux-system
directory.
I was following along, adding components to my repo - and everything works fine when the components are installed using Helm (as is the case in the blog). I've only seen the problem with the podinfo
component, which I'm installing using Flux kustomization git repo (same as in my minimal example above).
Actually, if I bootstrap Flux without the parent kustomization.yaml
file in my minimal example repo, I get the same behaviour with podinfo
resources being deleted after provisioning.
Then, if I add the parent kustomization.yaml
file, commit and push, Flux seems to try to uninstall itself.
OTOH, if I change the cluster folder structure (to the one used in the blog) and move "parent" YAML files to a platform
directory, which is alongside flux-system
directory:
├── clusters
| └── k8s-small
| ├── flux-system
| └── platform
| ├── kustomization.yaml
| └── podinfo.yaml
|
└── platform
└── podinfo
└── _base
├── kustomization.yaml
└── podinfo.yaml
I can start without the parent kustomization.yaml
file. Flux bootstrap will deploy podinfo
resources and immediately garbage-collect them. If I then add, commit and push the parent kustomization.yaml
file, Flux will not attempt to uninstall itself, but the podinfo/prune behaviour is still there.
You cannot have 2 Kustomizations with the same name in the same namespace, they will override each other. Same with the kustomization.yaml in the cluster dir. Your repo has both of these things, please follow the repo structure I posted above.
Oh my word... I understand now what you've been trying to explain :-). Both parent and child Kustomizations had the same name! What a silly mistake and a case of staring too hard into something and missing the obvious.
Thank you very much for your patience with silly me.
Hi all,
I'm trying to understand
prune
behaviour when using nested kustomizations. I hit this problem when trying to create a test repository with composable components, following this.I created a minimal sample trying to figure it out. My directories look like this:
When
prune
isfalse
in both Kustomizations,podinfo
resources get created as expected.When I set
prune
totrue
only in the "parent" Kustomization (clusters/k8s-small/podinfo.yaml
), any runningpodinfo
pods get deleted and then redeployed.flux logs
shows these lines:When I set
prune
totrue
only in the "child" Kustomization (platform/podinfo/_base/podinfo.yaml
), any runningpodinfo
pods get deleted.When I use the simple
podinfo
Kustomization structure fromflux
tutorial, everything works as expected, withprune
set totrue
.