A machine-readable index of this documentation for AI agents is available at https://kubevela.io/llms.txt. Markdown versions of documentation pages are available by appending .md to their URLs.
Skip to main content
Version: Next

Rolling Out Policy Changes

An Application-scoped policy is rendered against every Application it applies to. Policies don't stand still, though: a platform team publishes a new version, or the data a policy reads (a Namespace label, a ConfigMap, an external API) changes underneath it. KubeVela then has to decide what happens to the Applications that are already running. This page explains those decisions, the settings that control them, and how to see what was decided.

Make sure you have read Application-Scoped Policies first.

An Example​

Say your platform team runs a global platform-labels policy that stamps every Application with platform.io/managed-by: kubevela. You publish a new version that also adds platform.io/cost-centre.

With the default settings, nothing happens to the Applications that are already running. Each one keeps rendering the version it was deployed with, and reports the new version as pending. The new version reaches an Application at its next revision: when its owner edits it, or bumps app.oam.dev/publishVersion. Brand-new Applications take the new version straight away.

If you want the new label everywhere now, set applyPolicyUpdates: true in the policy's template and publish it. Each running Application then adopts the new version on its next reconcile. Publishing a PolicyDefinition does not trigger one, so that is normally the next resync: every five minutes by default (application-re-sync-period), or the Application's own app.oam.dev/reconcile-interval where it sets one. A busy or restarting controller can take longer. On that reconcile KubeVela cuts a new ApplicationRevision and re-runs the workflow, with no edit to the Application, and the Application and its resources take the new version's labels, annotations and context.

The rest of this page covers the three kinds of change, where the settings come from, and the cases where a change is held back whatever the settings say.

Three Kinds of Change​

Every Application revision records the PolicyDefinitions it was rendered with. A change to an Application's own spec (an author edit, its first deployment, or a publishVersion bump) cuts a new revision, and a new revision always takes the live policies and their current data. The settings on this page decide what happens between those revisions, and there is one for each kind of change:

ChangeExampleControlled by
A new policy versionA platform engineer edits, adds or deletes a PolicyDefinitionapplyPolicyUpdates (a new version that rewrites the spec waits for the next revision)
A data changeThe policy is unchanged, but what it reads (a Namespace label, a ConfigMap, an API) now returns something else, so its output differsapplyDataChanges
A spec rewriteThe policy's output.components, output.workflow or output.policies replaces part of the Application specautoRevision

When a setting lets its change through, a new policy version cuts a new ApplicationRevision and re-runs the workflow, as in the example above. A data change reaches the Application's resources and components without a new revision, and the workflow does not re-run. A spec rewrite cuts a new ApplicationRevision.

All three settings default to off

With the defaults, a running Application keeps the policy versions and data it was deployed with until its next revision. The newer version or data is reported as pending, not applied. Turn a setting on per policy, per Application or for the whole controller, as described below, when you want changes to reach running Applications.

Where a Setting Comes From​

Each setting can be given in three places: the policy's template, an annotation on the Application, and a controller-wide default.

SettingTemplate fieldApplication annotationChart value (controller flag)Default
Adopt new policy versionsconfig.applyPolicyUpdatespolicy.oam.dev/apply-policy-updatescontrollerArgs.defaultApplyPolicyUpdates (--application-default-apply-policy-updates)false
Take data changes without a new revisionconfig.applyDataChangespolicy.oam.dev/apply-data-changescontrollerArgs.defaultApplyDataChanges (--application-default-apply-data-changes)false
Cut a new revision for a spec rewriteconfig.autoRevisionpolicy.oam.dev/auto-revisioncontrollerArgs.defaultAutoRevision (--application-default-auto-revision)false

KubeVela works each setting out per policy, for each Application, in this order:

  1. The Application's annotation, if it is set and valid. A list decides for every policy: a policy it names is on, and a policy it leaves out is off. Neither falls back to the template or the default.
  2. The policy template's config field, if the template sets it.
  3. The controller default from the chart value.
A platform team cannot push a change past an Application's annotation

An Application whose annotation turns a setting off for a policy ("false", or a list that leaves the policy out) holds the changes that setting covers (new versions, or data changes) between revisions, whatever the template or the controller default says. That includes a security fix in a new policy version: it reaches that Application only at its next revision, when its owner edits it or bumps app.oam.dev/publishVersion. If a policy change must reach every Application at once, check which Applications carry these annotations first.

Template Fields​

The settings sit next to config.enabled in the policy's template. They are evaluated with the Application's context, so a template can decide per Application. This one rolls out its own new versions straight away, and takes data changes everywhere except in the production namespace:

"platform-labels": {
attributes: {
scope: "Application"
global: true
}
description: "Platform identity labels."
type: "policy"
}

template: {
parameter: {}

config: {
enabled: true
// New versions of this policy roll out to running Applications straight away...
applyPolicyUpdates: true
// ...and so do changes in the data it reads, except in the production namespace.
applyDataChanges: context.namespace != "production"
}

output: labels: {
"platform.io/managed-by": "kubevela"
}
}

It's the new version's own applyPolicyUpdates that decides whether that version is adopted, so publishing a version that sets applyPolicyUpdates: true rolls it out, except to an Application whose policy.oam.dev/apply-policy-updates annotation says otherwise.

A value that is not a boolean is ignored, and the Application gets a PolicySettingIgnored Warning event naming the field. A rollout setting never makes a policy fail.

Annotation Values​

An Application owner can choose for themselves with an annotation. Each annotation takes "true" (every policy), "false" (no policy) or a comma-separated list of PolicyDefinition names (only those):

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: payments
annotations:
# Adopt new versions of these two policies; hold every other policy's updates.
policy.oam.dev/apply-policy-updates: "platform-labels,tenant-identity"
# Never take data changes between revisions.
policy.oam.dev/apply-data-changes: "false"
spec:
components:
- name: api
type: webservice
properties:
image: payments/api:1.4.2

Use the PolicyDefinition name in a list, without any @version suffix. An annotation that cannot be read (empty, or a name that cannot be a PolicyDefinition) is ignored for that setting, which falls back to the template and the default. A listed name that matches no policy applied to the Application is reported but harmless. Both give a PolicySettingIgnored Warning event.

Controller Defaults​

To change the default for every policy that doesn't set its own, set the chart values:

helm upgrade --install kubevela kubevela/vela-core -n vela-system \
--set controllerArgs.defaultApplyPolicyUpdates=true \
--set controllerArgs.defaultApplyDataChanges=true

New Policy Versions​

Between revisions, on each reconcile, KubeVela compares the live PolicyDefinitions with the versions pinned in the Application's latest revision. A policy that was edited, added or deleted is a changed policy. With applyPolicyUpdates on for that policy, the new version is adopted: the Application renders with it and a new revision is cut, and its labels and annotations reach the Application and its resources. With it off, the update is held: the Application keeps rendering the pinned version, and the policy is reported as pending until the Application's next revision adopts it.

Some updates are held whatever the setting says.

A new version that fails to render is held rather than applied, and the pinned version keeps the Application running. If it failed because of something it reads, such as a missing ConfigMap, fixing that can take up to ten minutes to reach the Application, because KubeVela remembers a held update for that long rather than rendering it on every reconcile. Publishing a corrected version, or any change to the Application, decides again straight away.

Adoption is decided in sequence. Policies run as a chain (see Priority), so a new version is tried in its place in that chain, after the policies before it. A new version that only fails next to the others is held.

A new version that rewrites the spec stays pinned until the next revision, even with applyPolicyUpdates on. Spec rewrites are covered by autoRevision, in Spec Rewrites.

A deleted policy is a changed policy too. Its removal follows the settings its own template last set (they are recorded when it renders), then the annotation and the default. Until the removal is adopted, the deleted policy keeps applying from the pinned revision.

A publishVersion pin holds every update until app.oam.dev/publishVersion changes. Bumping it cuts a new revision, which takes the live policies like an author edit does.

You can see a held update in three places. The policy's entry in status.appliedApplicationPolicies has a message that starts update pending: and says why: a newer version of this policy is held by policy.oam.dev/apply-policy-updates or a publishVersion pin, a newer version of this policy fails to render, or a newer version of this policy rewrites the application spec. The Application gets a PolicyUpdatePending event. And vela policy view <app> --details prints each policy's effective settings.

Data Changes​

A policy that reads the cluster or an external API can produce different output without changing its template: someone edits a Namespace label, or a ConfigMap value changes. That is a data change.

With applyDataChanges on for that policy, the changed output reaches the Application without a new revision and without re-running the workflow. Changed labels and annotations are written to the Application and its dispatched resources, and a changed output.ctx re-applies the Application's components, pruning what a component no longer renders. Workflow steps that read context.custom keep the old value until the next revision, since the workflow does not run again. With it off, the policy keeps contributing the output it last applied. The change is reported as data change pending in its status message, and applies at the Application's next revision. A publishVersion pin holds data changes too, until it moves.

To tell a data change from a policy that is simply rendering the same thing again, KubeVela records each policy's applied output in the Application's policy ConfigMap, and a hash of each policy's context output on the Application's current ResourceTracker (app.oam.dev/policy-context-hash). An Application deployed before that hash existed records one on its next reconcile, without redeploying.

With applyDataChanges on, a refresh writes a policy's new label or annotation value onto every dispatched resource that already carries that key, even where a trait set the key to something else on that resource.

A held policy's data can still reach a later policy

Holding swaps a policy's output for its last applied output after the policy chain has rendered. A later policy in the chain that reads the held policy's results during render (for example through context.appLabels) sees the new data, and its own output is built from it. If a later policy derives values from an earlier one, give both the same applyDataChanges setting.

Spec Rewrites​

A policy that sets output.components, output.workflow or output.policies rewrites the Application spec. With autoRevision on for that policy, a rewrite that differs from the latest revision cuts a new revision and is deployed. With it off, the Application keeps the components, workflow and policies stored in its latest revision, and the rewrite takes effect at the next revision.

A rewrite only counts when it differs from what the latest revision stores. A policy that rewrites the spec the same way on every reconcile cuts no revision, and does not stop another policy's update from being adopted.

What Holds a Change Back​

Putting the sections above together, a change waits for the Application's next revision when its setting is off for that policy (see New Policy Versions, Data Changes and Spec Rewrites), or when a publishVersion pin has not moved. A new version that fails to render, or that rewrites the spec, waits too, as described in New Policy Versions. A mandatory global policy that fails holds the whole Application: see Mandatory Global Policies.

An explicit policy pinned with @version in spec.policies (type: add-team-labels@v2) stays where it is pinned. @v2 names DefinitionRevision add-team-labels-v2, which is a hard pin. For a definition with semantic versions (spec.version), name the full version (@v2.1.0): @v2 resolves to the newest 2.x only on an Application annotated app.oam.dev/autoUpdate: "true".

Removing What a Policy Stops Setting​

When a policy stops setting a label or annotation (a new version drops it, the data no longer yields it, or the policy is deleted and its removal is adopted), KubeVela takes the key off the Application and off its dispatched resources.

It only removes what it knows the policies put there. The key must still hold the value the policy set: if someone has changed it since, it's theirs, and it stays. Keys from before KubeVela kept a record are not removed either. The record is the metadata entry of the policy ConfigMap, so a key set before it existed is left alone, and an Application with no policy ConfigMap has nothing removed.

A removal seen while the workflow is suspended is kept in the ConfigMap's pending_removals entry, and applied to resources once the workflow resumes. Keys an Application filters from inheritance are left alone on its resources: a key listed in filter.oam.dev/label-keys or filter.oam.dev/annotation-keys is never written to or removed from the resources by a policy refresh, since a full render would not put it there.

Two cases where a removal goes wrong

An author's own key with the same value is removed too. If an Application author sets a label to exactly the value a policy set, KubeVela cannot tell the two apart, and removes it when the policy stops setting it. Use a different key, or a different value, for anything an author must own.

ConfigMaps, Secrets and CRDs keep removed keys. KubeVela records no last-applied configuration for those kinds, so the three-way merge that removes a key from other resources cannot remove it from them. The key stays on the resource until something else removes it.

Revoking a bad global policy

Deleting a global policy is itself a policy change. With applyPolicyUpdates off (the default), the deleted policy's labels stay on existing Applications until their next revision. If you may need to pull a policy back quickly, decide on applyPolicyUpdates before you need it.

Rolling Back​

Rolling an Application back to an earlier revision's spec is an edit like any other: it renders with the live policy versions and their current data, not the versions pinned in that revision. A rollback restores what the author wrote, not the policies or the data of the time.

Seeing What Happened​

Each Application's status.appliedApplicationPolicies has one entry per policy: whether it applied or was skipped, its source (global or explicit), the definition revision used, and a message for pending updates and data changes. status.applicationPoliciesConfigMap names the Application's policy ConfigMap, application-policies-<namespace>-<name> in the Application's namespace, which holds the record KubeVela works from (its entries are listed under The Policy ConfigMap). The Application's events say what was applied, skipped or held, and vela policy view <app> --details prints each policy's labels, annotations, context and spec changes, its effective rollout settings, and its context schema.

Previewing with vela policy dry-run​

vela policy dry-run renders an Application's policies with the controller's own code, and writes nothing to the cluster. Which global policies apply depends on two controller flags (see Global Policies), and the CLI cannot read them from the controller, so pass the controller's values, or the result can differ from what the controller does:

vela policy dry-run my-app \
--allow-namespace-global-policies=false \
--allow-skip-global-policies=false

Both flags default to false, as the chart does. The output starts with the values it assumed:

Assumed controller flags: --allow-namespace-global-policies=false --allow-skip-global-policies=false

With -o json or -o yaml the same values are in assumedControllerFlags.

Choosing Settings​

tip

For informational tags (team, cost centre, managed-by), turn applyPolicyUpdates and applyDataChanges on in the template. Changes reach every Application within a resync, with no change to the Application: a new version cuts a revision, and changed data doesn't.

For policies that change behaviour, leave the settings off and let each Application adopt the new version at its next revision. Owners who want it sooner can opt in with the annotation.

Set the cluster-wide defaults (the controller flags, Helm controllerArgs.*) only once your policies are written to be safe to roll out live.

Upgrading from an Earlier Release​

Global policies outside vela-system stop applying unless the controller runs with --allow-namespace-global-policies, and policy.oam.dev/skip-global is ignored unless it runs with --allow-skip-global-policies. The two are independent. Before upgrading, find global PolicyDefinitions outside vela-system and Applications carrying skip-global. For each, either move the policies to vela-system (and check the Applications are fine taking them), or set the matching chart value to true to keep the earlier behaviour.

A namespace global that stops applying is a deleted policy for the Applications it covered. Its labels come off when its removal is adopted, following the rollout settings.

Existing Applications keep running as deployed. With the default settings, nothing changes for them until their next revision, apart from pending updates now being reported.

Reference​

Annotations and Labels​

These are the annotations and labels the rollout works with. The first six are set by Application authors; the rest KubeVela manages itself.

KeySet onSet byValuesEffect
policy.oam.dev/skip-globalApplicationApplication author"true"Opts the Application out of global policies, only while the controller runs with --allow-skip-global-policies. Otherwise it is ignored with a GlobalPolicySkipIgnored event, and adding it is refused. See Opting Out of Global Policies.
policy.oam.dev/apply-policy-updatesApplicationApplication author"true", "false", or PolicyDefinition namesWhether the Application adopts new versions of the policies it runs. See New Policy Versions.
policy.oam.dev/apply-data-changesApplicationApplication author"true", "false", or PolicyDefinition namesWhether changed output from an unchanged policy version reaches the Application without a new revision. See Data Changes.
policy.oam.dev/auto-revisionApplicationApplication author"true", "false", or PolicyDefinition namesWhether a policy's spec rewrite cuts a new revision. See Spec Rewrites.
app.oam.dev/publishVersionApplicationApplication authorany version stringPins the Application: policy updates and data changes are held until the value changes, and a new value takes the live policies. See Version Control.
filter.oam.dev/label-keys, filter.oam.dev/annotation-keysApplicationApplication authorcomma-separated keysKeys not copied from the Application to its resources. A policy refresh leaves them alone on resources.
app.oam.dev/policy-context-hashResourceTrackerKubeVelaJSON map of policy instance (global:<name>, or the spec.policies name) to hashThe hash of each policy's context output when the components were last applied. Used to detect data changes in output.ctx.
app.oam.dev/application-generationApplicationRevisionKubeVelathe Application's generationThe Application generation the revision was written for. Used to tell an author's edit from a policy's spec rewrite.
app.oam.dev/application-policiesConfigMapKubeVela"true"Marks an Application's policy ConfigMap, with app.oam.dev/name, app.oam.dev/namespace and app.oam.dev/uid naming the Application.
policydefinition.oam.dev/nameDefinitionRevisionKubeVelaPolicyDefinition nameLinks a PolicyDefinition's revisions to it, for versioning.

A policy template cannot read any of the KubeVela-managed keys above: context.appLabels and context.appAnnotations leave out internal prefixes. See Context Variables for the list.

Controller Flags and Chart Values​

These are the controller settings that shape how policies roll out.

Chart valueController flagDefaultEffect
featureGates.enableApplicationScopedPolicies--feature-gates=EnableApplicationScopedPolicies=truefalseTurns Application-scoped policies on. Needed for everything on this page.
featureGates.enableGlobalPolicies--feature-gates=EnableGlobalPolicies=truefalseTurns global policies on.
controllerArgs.allowNamespaceGlobalPolicies--allow-namespace-global-policiesfalseLets a global policy outside vela-system apply to the Applications in its own namespace.
controllerArgs.allowSkipGlobalPolicies--allow-skip-global-policiesfalseLets an Application opt out of global policies with policy.oam.dev/skip-global.
controllerArgs.defaultApplyPolicyUpdates--application-default-apply-policy-updatesfalseDefault for applyPolicyUpdates.
controllerArgs.defaultApplyDataChanges--application-default-apply-data-changesfalseDefault for applyDataChanges.
controllerArgs.defaultAutoRevision--application-default-auto-revisionfalseDefault for autoRevision.

Events​

These are the events an Application gets from its policies.

ReasonTypeWhen
GlobalPolicyApplied / PolicyAppliedNormalA global or explicit policy applied.
GlobalPolicySkipped / PolicySkippedNormalA policy was skipped, for example with config.enabled: false.
GlobalPolicyFailed / PolicyFailedWarningA policy failed to render.
GlobalPolicyHeldWarningA mandatory global policy fails, and the Application is held at its current revision. See Mandatory Global Policies.
GlobalPolicyIgnoredWarningA global policy in the Application's namespace does not apply, because global policies must be in vela-system.
GlobalPolicySkipIgnoredWarningThe Application carries policy.oam.dev/skip-global, but global policies are mandatory.
PolicyUpdatePendingNormalNewer versions of the named policies are held by apply-policy-updates, a publishVersion pin, a render failure or a spec rewrite.
PolicySettingIgnoredWarningA rollout annotation or template setting could not be read, or names a policy the Application does not run.

Conditions​

The GlobalPolicies condition shows when an Application is held by a failing global policy.

TypeStatusMeaning
GlobalPoliciesFalseA mandatory global policy fails to load or render; the message names it and the error. The Application is held at its current revision.
GlobalPoliciesTrueSet when a held Application's global policies render again. An Application that was never held has no GlobalPolicies condition.

The Policy ConfigMap​

The Application's policy ConfigMap holds the record KubeVela works from. Its entries:

KeyHolds
infoWhen the policies last rendered, how many applied, whether the result came from the cache, and whether a spec rewrite was set to cut a revision.
rendered_spec, applied_specThe spec the policies rendered, and the spec that was applied.
metadataThe labels, annotations and context the policies set, used to work out removals.
applied_outputsEach policy's last applied output, used to hold data changes.
pending_removalsRemovals still to be applied to resources.
NNN-<policy>One entry per policy, prefixed with its zero-padded render order, with its output, settings and the settings its template set.