Skip to main content
Version: v3.22.x

API Reference

This page lists Gatekeeper's Custom Resource Definitions (CRDs) and provides a quick reference for commonly configured fields in Gatekeeper v3.22.x. It is not an exhaustive schema reference: use the schemas and examples for complete field definitions and the linked feature guides for usage examples. Required fields and defaults below include Gatekeeper's validation rules, not only OpenAPI schema requirements.

To inspect the live schema in a cluster:

kubectl get crds | grep gatekeeper
kubectl explain configs.config.gatekeeper.sh.spec
kubectl explain constrainttemplates.templates.gatekeeper.sh.spec

Constraint kinds (for example K8sRequiredLabels) are not shipped as static CRDs. Gatekeeper creates those CRDs at runtime when you apply a ConstraintTemplate. Their shared constraint fields are documented below.

CRD catalog​

KindAPI groupScopePurpose
ConstraintTemplatetemplates.gatekeeper.shClusterDefines Rego/CEL policy and the schema for a constraint kind
Constraint (dynamic)constraints.gatekeeper.shClusterInstantiates a template with match criteria, enforcement mode, and parameters
Configconfig.gatekeeper.shNamespacedGatekeeper configuration (sync, exemption matchers, validation traces)
SyncSetsyncset.gatekeeper.shClusterDeclares additional GVKs for Gatekeeper to cache
Assignmutations.gatekeeper.shClusterMutate object fields outside metadata
AssignMetadatamutations.gatekeeper.shClusterAdd missing metadata labels/annotations
AssignImagemutations.gatekeeper.shClusterMutate container image strings
ModifySetmutations.gatekeeper.shClusterMerge or prune list values
ExpansionTemplateexpansion.gatekeeper.shClusterExpand generator resources (for example Deployments) into child objects for policy
Connectionconnection.gatekeeper.shNamespacedConfigures audit export drivers/connections
Providerexternaldata.gatekeeper.shClusterRegisters an external data provider
*PodStatus kindsstatus.gatekeeper.shNamespacedPer-pod status reported by Gatekeeper controllers (read-only operational data)

ConstraintTemplate (templates.gatekeeper.sh)​

Preferred version: v1 (also served: v1beta1, v1alpha1).

FieldTypeDescription
spec.crd.spec.names.kindstringRequired kind name for constraints created from this template (for example K8sRequiredLabels)
spec.crd.spec.names.shortNames[]stringOptional short names for kubectl
spec.crd.spec.validation.openAPIV3SchemaobjectOptional schema for the constraint spec.parameters field; v1 templates use a structural schema
spec.crd.spec.validation.legacySchemaboolEnable legacy schema mode; defaults to false in v1, but true in v1alpha1 and v1beta1
spec.targets[][]objectRequired policy target definitions
spec.targets[].targetstringRequired target identifier: admission.k8s.gatekeeper.sh
spec.targets[].regostringLegacy Rego policy source; alternatively use code
spec.targets[].libs[]stringOptional supporting libraries for the legacy Rego source
spec.targets[].code[][]objectEngine-specific policy definitions, each with engine and source
spec.targets[].code[].enginestringRequired for each code entry: Rego or K8sNativeValidation (CEL)
spec.targets[].code[].sourceobjectRequired engine-specific source; see Rego v1 and CEL sources
statusobjectRead-only template installation status observed by Gatekeeper

See Constraint Templates for examples and engine selection and field precedence. Defining multiple engines does not mean that all of them are evaluated.


Constraint resources (constraints.gatekeeper.sh/v1beta1)​

Each installed ConstraintTemplate registers a cluster-scoped constraint CRD whose kind matches spec.crd.spec.names.kind. All constraints share the following fields regardless of parameters schema.

spec fields​

FieldTypeDescription
spec.matchobjectOptional object selection. Matchers are AND-ed. Empty/undefined match selects everything.
spec.match.kinds[]objectList of {apiGroups, kinds} groups. A resource needs one matching entry.
spec.match.scopestring*, Cluster, or Namespaced (default *)
spec.match.namespaces[]stringInclude only these namespaces (prefix globs like kube-* allowed)
spec.match.excludedNamespaces[]stringExclude these namespaces (prefix globs allowed)
spec.match.labelSelectorobjectStandard label selector (matchLabels / matchExpressions) on the object
spec.match.namespaceSelectorobjectLabel selector on the object's namespace (or the object itself if it is a Namespace)
spec.match.namestringObject name or prefix glob
spec.match.sourcestringTarget resource origin: All, Generated, or Original (default All); see expansion matching
spec.parametersobjectTemplate-specific inputs; required fields and types depend on the template's OpenAPI schema
spec.enforcementActionstringOptional violation handling mode; defaults to deny (see below)
spec.scopedEnforcementActions[]objectRequired when enforcementAction is scoped; ignored otherwise

All match fields are optional. Namespace filters do not exclude non-Namespace cluster-scoped resources; set spec.match.scope: Namespaced to exclude those resources. See matching semantics.

spec.enforcementAction​

ValueBehavior
denyDefault. Admission requests that violate the constraint are rejected.
dryrunViolations are recorded (for example on the constraint status during audit) but admission is not blocked.
warnAdmission is allowed; clients receive a warning (Kubernetes 1.19+).
scopedUse spec.scopedEnforcementActions to choose different actions per enforcement point.

See Handling Constraint Violations and Enforcement Points.

spec.scopedEnforcementActions[]​

FieldTypeDescription
actionstringRequired: deny, warn, or dryrun for the listed enforcement points
enforcementPoints[][]objectRequired non-empty list of enforcement points
enforcementPoints[].namestringRequired: validation.gatekeeper.sh, audit.gatekeeper.sh, gator.gatekeeper.sh, vap.k8s.io, or * for all points

With enforcementAction: scoped, an enforcement point not named in any entry is excluded unless an entry names *. In particular, audit is not implicitly included. Native Kubernetes enforcement (vap.k8s.io) requires a CEL template and VAP/VAPBinding generation; see Enforcement Points.

status fields (observed)​

FieldDescription
status.byPod[].enforcedEnforcement status reported by each Gatekeeper controller pod
status.auditTimestampTimestamp of the latest audit run recorded in this constraint's status, including runs with zero violations
status.violations[]Bounded list of violations from the latest recorded audit run (enforcementAction, kind, name, namespace, message, ...)
status.totalViolationsTotal violation count from that audit run, including violations omitted from status.violations

The violation list is limited by --constraint-violations-limit (default 20); see Reading Audit Results.


Config (config.gatekeeper.sh/v1alpha1)​

Singleton configuration object. It must be named config in Gatekeeper's namespace (gatekeeper-system by default). Gatekeeper ignores Config resources with other names or namespaces.

All configuration sections below are optional.

FieldTypeDescription
spec.sync.syncOnly[][]object{group, version, kind} entries to replicate for referential policies; combined with all SyncSets, not an override of them
spec.match[][]objectProcess-specific configuration such as namespace exemptions
spec.match[].processes[]stringaudit, webhook, sync, mutation-webhook, or * for all processes; see namespace exemptions
spec.match[].excludedNamespaces[]stringNamespaces excluded for those processes (wildcards supported)
spec.validation.traces[][]objectAdmission trace requests; each needs user and kind (group, version, kind). Optional dump: All includes OPA state; see Tracing
spec.readiness.statsEnabledboolEnable readiness tracker stats (default false)

See replication with Config.


SyncSet (syncset.gatekeeper.sh/v1alpha1)​

Cluster-scoped list of GVKs to cache. The effective sync set is the union of all SyncSet objects plus Config.spec.sync.syncOnly.

FieldTypeDescription
spec.gvks[][]objectEntries with group, version, and kind

A resource remains cached while any SyncSet or Config still requests its GVK. Removing it from only one source does not stop replication. See replication with SyncSets.


Mutation CRDs (mutations.gatekeeper.sh)​

Assign, AssignMetadata, and ModifySet use v1 (also served: v1alpha1, v1beta1). AssignImage uses v1alpha1.

Common mutation fields:

FieldTypeDescription
spec.applyTo[][]objectRequired for Assign, AssignImage, and ModifySet; not supported by AssignMetadata. Each entry needs groups, versions, and kinds; globs are not allowed
spec.matchobjectOptional match criteria; empty/undefined criteria match everything
spec.locationstringRequired object path, for example spec.containers[name: main].image; see path syntax
spec.parametersobjectMutator-specific options
spec.parameters.pathTests[][]objectOptional subPath + condition (MustExist / MustNotExist) checks; each subpath must be a prefix of location. Supported by Assign, AssignImage, and ModifySet, not AssignMetadata; see conditionals

Gatekeeper v3.22.x does not support filtering mutators by admission operation. Mutators apply to matching resources for both CREATE and UPDATE requests handled by the mutation webhook.

Assign (v1)​

spec.parameters.assign must select exactly one of these value sources:

FieldTypeDescription
spec.parameters.assign.valueanyConstant value to assign; may be a scalar, list, or object
spec.parameters.assign.fromMetadata.fieldstringname or namespace from the object being mutated; see metadata assignment
spec.parameters.assign.externalDataobjectExternal provider configuration; see the external-data mutation API for provider selection, data sources, and failure policies

AssignMetadata (v1)​

Adds only missing metadata.labels / metadata.annotations entries. Existing labels and annotations are not overwritten. applyTo and pathTests are not supported.

FieldDescription
spec.parameters.assignExactly one of the Assign value sources; value must be a string. External data only supports dataSource: Username

See AssignMetadata for examples.

AssignImage (v1alpha1)​

FieldDescription
spec.parameters.assignDomainImage registry domain (no trailing slash)
spec.parameters.assignPathImage path/repository component
spec.parameters.assignTagTag or digest; must start with : or @

At least one image component is required. If assignPath could be interpreted as a domain, assignDomain must also be specified. See AssignImage.

ModifySet (v1)​

FieldDescription
spec.parameters.operationmerge (default) or prune
spec.parameters.values.fromListList values to merge into or prune from the location

See ModifySet.


ExpansionTemplate (expansion.gatekeeper.sh/v1beta1)​

Also served: v1alpha1.

FieldTypeDescription
spec.applyTo[][]objectGenerator resource GVKs to expand (for example Deployment, Job)
spec.templateSourcestringField on the generator used as the pod/template source (often spec.template)
spec.generatedGVKobject{group, version, kind} of the generated resource (for example Pod)
spec.enforcementActionstringOptional override for enforcement on expanded resources; empty defers to the constraint

See ExpansionTemplate behavior.


Connection (connection.gatekeeper.sh/v1alpha1)​

FieldTypeDescription
spec.driverstringRequired export driver name: dapr or disk
spec.configobjectRequired driver-specific configuration (preserved unknown fields); see export configuration

Create the Connection in Gatekeeper's namespace and select its name with --audit-connection. See Export for audit export configuration and enablement.


Provider (externaldata.gatekeeper.sh)​

Preferred version: v1beta1 (also served: v1alpha1, deprecated).

Registers an external data provider HTTPS service.

FieldTypeDescription
spec.urlstringRequired provider endpoint URL (must use the https:// prefix)
spec.timeoutintegerRequest timeout in seconds when querying the provider
spec.caBundlestringRequired base64-encoded TLS CA bundle in PEM format; see provider TLS configuration

See the Provider API for examples.


Status CRDs (status.gatekeeper.sh)​

Gatekeeper writes these namespaced resources so each controller pod can report health and errors. They are controller-owned operational data, not resources that users normally create or edit.

KindAPI version
ConfigPodStatusstatus.gatekeeper.sh/v1beta1
ConnectionPodStatusstatus.gatekeeper.sh/v1alpha1
ConstraintPodStatusstatus.gatekeeper.sh/v1beta1
ConstraintTemplatePodStatusstatus.gatekeeper.sh/v1beta1
ExpansionTemplatePodStatusstatus.gatekeeper.sh/v1beta1
MutatorPodStatusstatus.gatekeeper.sh/v1beta1
ProviderPodStatusstatus.gatekeeper.sh/v1beta1

Viewing schemas and examples​

These links use the Gatekeeper v3.22.2 release rather than the development branch.