- Disable the policy? No — that opens a large security hole.
- Make the policy extremely complex with many excludes? No — that’s hard to maintain.

- Team boundaries: a central security team owns cluster policies. Application teams should not have to request edits for each exception. PolicyException lets app teams create exceptions in a controlled, auditable way without touching the core policy.
- Simplicity: adding many exclude blocks to policies creates long, hard-to-read policies. Exceptions keep the policy logic simple and make temporary or emergency exceptions explicit.



--enablePolicyException— enable the PolicyException feature (true).--exceptionNamespace— which namespace(s) may contain PolicyException resources.
--exceptionNamespace to * to allow exceptions from any namespace, but that is only appropriate in less restrictive environments.
Enable the feature by adding
--enablePolicyException=true and set --exceptionNamespace (or *) in the Kyverno admission controller flags. The namespace value controls where PolicyException resources may be created.
hostPID, hostIPC, hostNetwork). This is a typical security rule, but a developer needs to run a debugging tool that must inspect host namespaces; the policy blocks it.

important-tool Deployment in the delta namespace to bypass the specific rule for debugging.

failureAction: Enforce means Kyverno will actively block any resource that violates the rule. That’s why the debugging tool cannot be created.
PolicyException blueprint
A PolicyException is explicit and answers three questions:
- Which policy and rule(s) to bypass? (
exceptionsblock) - Which resource(s) get the exception? (
matchblock) - (Optional) Under what extra conditions? (
conditionsblock)
policyNametargets the exact policy to bypass. For a namespaced policy use the formatnamespace/policy-name.ruleNamesmust list the rule names from the policy (or["*"]to bypass all rules).matchsupports the same selectors as Kyverno policies:kinds,namespaces,names,labelSelector, etc.conditionsare optional extra checks evaluated against the admission request or object.
delta namespace (which must be allowed by --exceptionNamespace). Important: Kyverno autogenerates rules for controller resources when a rule targets Pods. If a ClusterPolicy validates Pods, Kyverno creates corresponding autogen-... rules for Deployments, StatefulSets, Jobs, etc. To exempt a Deployment and its Pods, you must exempt both the original rule and the autogen rule.
Final PolicyException to solve Alex’s problem:
host-namespacesis the original ClusterPolicy rule applying to Pods.autogen-host-namespacesis the automatically generated rule that applies to controller resources (Deployment, StatefulSet, Job, etc.). Exempting both ensures both the Deployment and the Pods it creates are covered.
- For a namespaced policy, specify the policy name as
namespace/policy-name, for example:
- To bypass all rules in a policy, use:
Setting
--exceptionNamespace=* allows PolicyExceptions from any namespace. Use this only in trusted or non-production environments — wildcard exceptions increase risk.
Recap
- PolicyExceptions decouple temporary or special-case exceptions from core ClusterPolicies, improving maintainability and team autonomy.
- The feature is opt-in: enable it on the Kyverno admission controller with
--enablePolicyExceptionand restrict creation locations with--exceptionNamespace. - A PolicyException explicitly identifies the policy and rule(s) to bypass, the target resources, and optional conditions.
- Remember to include autogen rule names when you need to exempt controller resources (Deployments, StatefulSets, Jobs) in addition to Pods.

- Kyverno PolicyException docs: https://kyverno.io/docs/writing-policies/policyexception/
- Kyverno admission controller configuration: https://kyverno.io/docs/installation/#admission-controller
important-tool deployment without changing the central security policy.