Skip to content

[feature]: selective Kustomization reconcile in workload watch #3106

@github-actions

Description

@github-actions

User Story

As a developer using ksail workload watch on a large Kubernetes repo,
I want the watch command to reconcile only the Kustomization subtree affected by my file changes,
So that reconcile latency is minimised and I get faster feedback without waiting for unrelated Kustomizations to re-run.

Context

The Weekly Roadmap — March 16, 2026 identifies selective Kustomization reconcile as the third highest unshipped "Now" priority:

In repos with 10+ Kustomizations, full-tree reconcile latency is the dominant UX pain point. Selective reconcile significantly reduces iteration latency and converts workload watch from a convenience into a genuinely fast inner-loop tool. No new dependencies required.

ksail workload watch currently triggers a full reconcile of k8s/ (or spec.workload.sourceDirectory) on any file change. In large repos with multiple Kustomization overlays (e.g., k8s/clusters/, k8s/apps/, k8s/infra/), this causes unnecessary reconcile cycles for all unrelated Kustomizations.

Approach

  1. Map changed file → containing Kustomization — in the watch event handler, walk up the directory tree from the changed file path to find the nearest kustomization.yaml boundary.
  2. Resolve the Flux Kustomization CR — identify which Flux Kustomization CR references the changed subtree by matching spec.path in the cluster's Kustomization objects.
  3. Targeted reconcile — trigger flux reconcile kustomization (name) only for the affected Kustomization(s) via pkg/client/flux/ or pkg/client/reconciler/.
  4. Full reconcile fallback — if the mapping is ambiguous, the changed file is at the root level, or the targeted CR cannot be determined, fall back to the existing full reconcile.
  5. Preserve existing debounce/coalescing — maintain the existing debounce and event coalescing behaviour.

Key files:

  • pkg/cli/cmd/workload/watch.go (or equivalent watch lifecycle path) — event handler to modify
  • pkg/client/flux/ — Flux reconcile client
  • pkg/client/reconciler/ — common reconciler base
  • Watch infrastructure: wherever the file-change → reconcile trigger is wired

Acceptance Criteria

  • Changing a file in a Kustomization subtree triggers reconcile of only that subtree's Kustomization CR
  • Changing a top-level file (e.g., root kustomization.yaml) triggers full reconcile as before
  • Ambiguous or unmappable changes fall back to full reconcile (no silent failures)
  • Debounce and coalescing logic is preserved
  • Unit tests cover the changed file → Kustomization mapping logic
  • go build ./... and go test ./... pass
  • No regressions in existing workload watch behaviour

Generated by Daily Plan ·

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions