


Generate rules let Kyverno create new resources in response to events (like a Namespace creation). This is different from:
validaterules (which block or allow requests), andmutaterules (which modify the incoming resource). Usegeneratewhen you need Kyverno to produce a separate resource (e.g., a NetworkPolicy, Role, Secret).

NetworkPolicy when a Namespace is created. This example is simplified to show the structure:
generate block supports different patterns — embedding a manifest, cloning a named resource, or using cloneList to clone multiple resources. In later sections we’ll show concrete examples for each pattern, plus how to configure generation for existing Namespaces.
Avoid using
validate to enforce presence of resources that Kyverno can generate. Blocking Namespace creation is disruptive; instead, prefer generate to create required resources automatically or combine generate with monitoring policies to detect missing resources.- Automatically create NetworkPolicies, Roles, and other resources when Namespaces are created.
- Clone centrally managed “golden” resources into multiple Namespaces.
- Use
cloneListto bundle multiple clone operations. - Apply generation rules to existing Namespaces to bring the cluster into compliance.
- Kyverno generate rules — https://kyverno.io/docs (see “Generate” section)
- Kubernetes Namespaces — https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
- Best practices for NetworkPolicy — https://kubernetes.io/docs/concepts/services-networking/network-policies/