Skip to content

Feature Request: Support spec.resources in Kustomization CRD #1587

@lictw

Description

@lictw

Description
Currently, the kustomize-controller can automatically generate a kustomization.yaml if it's missing in the spec.path. However, it lacks the ability to explicitly define a list of resources via the CRD.

While Flux is often presented as a "transport," in reality, it is already a powerful manifest generator: it allows overriding namespaces, names, patches, images, and variables. If Flux can manage "what to change" (patches), it should be able to manage "what to include" (resources).

The "Components" Precedent
Flux already supports spec.components, which allows injecting a list of files/directories. Since the controller already implements logic for injecting a list of components into the transient kustomization.yaml, forbidding the same for resources is an artificial and inconsistent limitation.

Proposed Change
Add a spec.resources field (list of strings) to the Kustomization CRD.

Expected Behavior

  1. Context: spec.path serves as the root (work directory).
  2. Explicit Selection: If spec.resources is defined, the controller uses this list and disables the default automatic recursive discovery (the "include all files" behavior).
  3. Merging: If a physical kustomization.yaml exists in spec.path, spec.resources should be appended/merged (following the same merging logic already used for spec.components).

Why this is needed?

  • Reducing Git Boilerplate: Currently, users are forced to create "garbage" one-liner overlays in Git just to have different resource lists for the same source.
  • Consistency: If we can dynamically inject components and patches via CRD, we must be able to define the base resource list.
  • Logical Alignment: If spec.path is the "context," then spec.resources is the natural way to define the entry points within that context.

Example

apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: example
spec:
  interval: 5m
  path: ...
  resources: 
    - https://raw.githubusercontent.com/...
  components: # already work, why doesn't the resource list?
    - components/ingress

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions