Skip to content

Use local spec of nested Kustomizations - #6126

Open
sakiphan wants to merge 1 commit into
fluxcd:mainfrom
sakiphan:diff-recursive-local-spec
Open

sakiphan wants to merge 1 commit into
fluxcd:mainfrom
sakiphan:diff-recursive-local-spec

Conversation

@sakiphan

Copy link
Copy Markdown

Fixes #5294

When flux diff ks --recursive, or flux build ks --recursive without
--dry-run, processes a nested Kustomization that already exists in the
cluster, the builder uses the spec of the live object. Local changes to the
nested Kustomization (patches, path, targetNamespace, postBuild) are ignored,
and the diff only reports the Kustomization object itself as drifted.

To answer the question in the issue: --kustomization-file works for the root
Kustomization, because the local spec takes precedence there. Nested
Kustomizations had no equivalent. With this change the spec rendered from local
sources takes precedence for them too, and the live status is kept, so pruning
is still computed against the cluster inventory.

The new tests build and diff a nested Kustomization whose local spec adds a
patch that the cluster copy does not have. The test reset of
diffKsArgs.localSources is also fixed: running two diff tests with
--local-sources panicked on a nil map.

When building or diffing recursively, the spec of a nested
Kustomization was read from the cluster, and the spec rendered from
local sources was used only when the object did not exist. Changes
made in Git to a nested Kustomization, such as patches or path, were
not reflected in the output.

Prefer the rendered spec and keep the live status, so pruning is
still computed against the cluster inventory.

Also reset the diff --local-sources flag between tests to avoid
writing into a nil map.

Signed-off-by: Sakıp Han Dursun <sakiphann@gmail.com>
Assisted-by: Claude Code/claude-opus-5-5

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flux diff does not show changes applied by a flux Kustomization patch

1 participant