Skip to content

Conversation

@remo-lab
Copy link

@remo-lab remo-lab commented Jan 26, 2026

What this PR does

This PR adds a new optional field, spec.useServerSideApply, to GeneratingPolicy (and NamespacedGeneratingPolicy) specs.

This brings GeneratingPolicy in line with existing behavior in ClusterPolicy / Policy, where users can choose between:

  • traditional Create/Update
  • or Kubernetes Server-Side Apply (SSA)

Why this is needed

Currently:

  • useServerSideApply exists for generate rules in ClusterPolicy / Policy
  • but GeneratingPolicy does not expose this option
  • generated resources from GeneratingPolicy always use Create/Update

This is limiting for users running:

  • multiple controllers managing the same resources
  • environments that rely on SSA field ownership
  • modern GitOps-style workflows

This gap is tracked in Issue [(https://github.com/kyverno/kyverno/issues/14853)].


What changed

  • Added UseServerSideApply field to:

    • GeneratingPolicySpec
    • (and NamespacedGeneratingPolicy spec where applicable)
  • Field is optional and defaults to false

  • Includes comments and JSON tags consistent with existing API patterns

  • CRDs regenerated accordingly

// UseServerSideApply controls whether to use server-side apply for generate rules.
// If set to true, generated resources will be created and updated using SSA.
// Defaults to false.
UseServerSideApply bool `json:"useServerSideApply,omitempty"`

How this relates to the Kyverno implementation

This PR only defines the API contract.

A follow-up PR in the main kyverno/kyverno repository:

  • reads this field from the policy spec

  • passes it through the CEL engine and controllers

  • switches resource creation/update logic between:

    • CreateResource / UpdateResource
    • and ApplyResource when SSA is enabled

Keeping the API change separate makes the review smaller and cleaner, and avoids mixing API evolution with controller logic.


Backward compatibility

  • Fully backward compatible
  • Existing GeneratingPolicies continue to behave exactly the same
  • SSA is opt-in only

Related issue

  • Fixes / implements: #14853

Signed-off-by: remo-lab <remopanda7@gmail.com>
@remo-lab
Copy link
Author

Hey @eddycharly ,
This PR adds the API field needed for useServerSideApply support in GeneratingPolicy.
A follow-up PR in kyverno/kyverno wires this through the engine and controllers to actually enable SSA for generated resources.
Would really appreciate a quick review when you get a chance — thanks!

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.

1 participant