All Linux Foundation / CNCF exams
Free KCA practice test: 30 questions with answers
30 original questions for Kyverno Certified Associate (KCA), drawn from every topic area. Answer each one to see whether you got it right and why. No sign-up.
- Free questions
- 30
- Full bank
- 112 questions
- Real exam
- 90 min
All 30 KCA questions with answers
The same questions as the test above, grouped by exam topic. Open any question to see the answer and explanation.
Writing Policies (5 questions)
Question 1
A team wants Pods that run containers as root to be rejected. Which rule design expresses this most directly?
- AA cleanup policy that removes Pods every hour when they are found to run as root
- BA generate rule that creates a companion ConfigMap listing every container in the cluster that is currently running as root
- CA mutate rule that deletes any Pod whose image name contains the word root
- DA validate rule that matches Pods and requires runAsNonRoot to be set to true in the security context
Show answer and explanationHide answer
Correct answer: DA validate rule with a pattern can require the runAsNonRoot setting, so non-compliant Pods are rejected at admission. Generate creates other objects, mutate changes objects rather than deleting them, and cleanup removes resources on a schedule instead of blocking creation.
Question 2
A policy must add a default owner label to every Service that lacks one, and it must keep any value that a user has already set. Which approach fits?
- AA generate rule that creates a second copy of each Service with the owner label set on the copy
- BA mutate rule that adds the owner label only when the field is absent, leaving existing values untouched
- CA validate rule with a deny condition that rejects every Service that does not carry the owner label
- DA cleanup policy that removes Services without an owner label at the end of each day, so that the platform stays tidy
Show answer and explanationHide answer
Correct answer: BA mutate rule can fill in missing fields, and an add-if-absent style patch keeps values users have already set. Validate rules reject rather than fill in defaults, generate creates new objects, and cleanup deletes resources on a schedule.
Question 3
A rule clones a shared ConfigMap into every new Namespace. An administrator later edits the source ConfigMap and expects the copies to follow. Which generate setting makes this happen?
- ASetting validationFailureAction to Audit, so edits to the source are logged against the copies
- BAdding a mutate rule that writes the source ConfigMap name into every Pod in the cluster
- CSetting synchronize to true, so Kyverno keeps the generated copies in step with the source
- DEnabling autogen, so that a copy of the ConfigMap is created for each Deployment in each Namespace
Show answer and explanationHide answer
Correct answer: CThe synchronize field on a generate rule tells Kyverno to keep generated resources in sync with their source. Audit mode only affects how validation results are reported, a mutate rule does not copy ConfigMaps, and autogen extends Pod rules to pod controllers rather than creating copies.
Question 4
A cluster may only run container images that were signed with the platform team's signing key. Which Kyverno rule type handles this requirement?
- AA validate rule that compares the image name with a fixed list of approved strings
- BA cleanup rule that deletes images from the registry once they are older than a set age
- CA verifyImages rule that checks image signatures against the trusted keys or attestors listed in the rule
- DA mutate rule that renames each image tag so that it includes the word signed, which records that the image was verified
Show answer and explanationHide answer
Correct answer: CA verifyImages rule looks up signatures for matching image references and checks them against the keys or attestors the rule lists. A name list cannot prove who signed an image, cleanup rules delete Kubernetes resources rather than registry images, and renaming a tag does not establish a signature.
Question 5
In a Kyverno rule, what does a context entry that uses an API call provide?
- AA change to the match block that widens the rule so it applies to every resource in the cluster
- BData fetched from the Kubernetes API or an external service, which rules can reference through variables and conditions
- CA copy of the admission request sent to the audit log so it can be kept for long-term storage and reviewed later by auditors
- DA direct connection from each Pod to the API server, which replaces the admission webhook
Show answer and explanationHide answer
Correct answer: BContext entries load extra data, such as the result of an API call, that rule conditions and variables can use. The other options describe audit logging, a bypass of the admission webhook, and a change to matching, none of which is what an API call context entry does.
Fundamentals of Kyverno (5 questions)
Question 6
A platform team wants every new Namespace to carry a cost-center label. Developers should not be able to create a Namespace without it. Which Kyverno construct expresses this requirement?
- AA ConfigMap that lists the required label keys and is read by the scheduler
- BA ResourceQuota that caps how many labels and annotations each Namespace is allowed to carry
- CA NetworkPolicy that drops network traffic from any Namespace that is missing the required label
- DA Kyverno policy with a validate rule that matches Namespaces and checks for the label
Show answer and explanationHide answer
Correct answer: DA validate rule in a Kyverno policy can match Namespace resources at admission and reject any request whose object lacks the label. A ConfigMap does not enforce anything by itself, a NetworkPolicy controls network traffic rather than object metadata, and a ResourceQuota limits resource consumption, not labels.
Question 7
What is the main difference between a validate rule and a mutate rule in a Kyverno policy?
- AA validate rule creates companion objects in other namespaces, while a mutate rule deletes stale objects on a schedule
- BA validate rule rewrites the incoming object to match a desired state, while a mutate rule only accepts or rejects it
- CA validate rule accepts or rejects a request based on its content, while a mutate rule changes the object before it is stored
- DA validate rule can only target Pods, while a mutate rule can target any kind of Kubernetes resource listed in its match block
Show answer and explanationHide answer
Correct answer: CValidate rules evaluate the object and allow or reject the request (or only report the result in audit mode), whereas mutate rules patch the object, for example to add a default label. Option A reverses the roles of unrelated rule types, B swaps validate and mutate, and D is wrong because both rule types can target any kind named in their match block.
Question 8
A teammate writes a new Kyverno ClusterPolicy manifest. Which three top-level fields must a Kubernetes object manifest include, so the API server knows the resource type and name?
- Akind, spec, and rules
- BapiVersion, kind, and metadata
- Cmetadata, data, and spec
- DapiVersion, kind, and status fields, which the author fills in with the current state before the manifest is applied
Show answer and explanationHide answer
Correct answer: BEvery Kubernetes object manifest declares apiVersion, kind, and metadata, which identify the resource type and its name. The status field is written by the system rather than authored, rules is nested under spec rather than at the top level, and data is a ConfigMap-specific field.
Question 9
Which statement correctly describes how Kyverno's admission controller fits into the Kubernetes API request flow?
- AIt receives requests from the API server through webhooks and can allow, deny, or patch them before they are persisted
- BIt schedules Pods onto suitable nodes after the kube-scheduler has finished choosing a placement for them
- CIt runs as a sidecar in each Pod, inspects container network traffic for policy breaches, and reports each breach to the administrator
- DIt replaces etcd as the cluster datastore and keeps a full copy of every resource definition in its own database
Show answer and explanationHide answer
Correct answer: AThe Kubernetes API server calls Kyverno's admission webhooks during a request, and Kyverno can allow, deny, or patch the object before it is stored. Kyverno does not replace etcd, does not schedule Pods, and is not a per-Pod sidecar that inspects traffic.
Question 10
An administrator creates a mutating policy that adds a default label to new Pods and a validating policy that checks the label value against an approved list. A Pod is submitted without the label. What happens?
- AThe validating check runs first and rejects the Pod because the label is missing, before mutation can run
- BBoth policies evaluate at the same time, and whichever finishes first decides whether the Pod is saved
- CThe label is added by the mutating step first, and then the validating step checks the resulting value
- DThe Pod is saved without evaluation, because mutating policies are excluded from the validating step
Show answer and explanationHide answer
Correct answer: CKubernetes runs mutating admission before object schema validation and validating admission, so the default label is already present when the validating policy runs. The other options describe an order or behaviour that does not exist in the admission chain.
Installation, Configuration, and Upgrades (5 questions)
Question 11
A cluster operator wants to install Kyverno in a way that can be repeated across clusters, with the settings kept in version control. Which approach fits best?
- ARun kyverno apply against the cluster so that it creates the controller Deployments for it
- BApply the release manifests with kubectl and then edit each Deployment by hand in the running cluster to set the required values
- CCopy the Kyverno controller binary to each node and start it with a systemd unit file
- DInstall the official Kyverno Helm chart and pass a values file that is stored in version control
Show answer and explanationHide answer
Correct answer: DThe official Helm chart accepts a values file, which can be versioned and reused for repeatable installs. Manual edits leave no reviewable record, a systemd unit would run the controller outside Kubernetes, and kyverno apply evaluates policies against resources rather than installing controllers.
Question 12
Why must the Kyverno custom resource definitions (CRDs) be present in a cluster before ClusterPolicy objects can be created?
- AThe CRDs are only needed when Helm is used to install Kyverno, and kubectl can create ClusterPolicy objects directly without them in any cluster
- BThe CRDs let the Kyverno CLI run tests offline, which means a cluster is not needed for policy work
- CThe CRDs keep a copy of every admitted resource so that policies can read earlier versions of it later
- DThe CRDs register the kyverno.io resource types and their schema with the API server, so policy objects can be stored and validated
Show answer and explanationHide answer
Correct answer: DCustom resource definitions teach the API server a new resource type and its schema, which is what allows ClusterPolicy objects to be stored and validated. CRDs do not hold copies of admitted resources, kubectl needs them just as Helm does, and the offline CLI does not depend on CRDs being installed in a cluster.
Question 13
A generate rule is meant to create a NetworkPolicy in each new Namespace. The background controller logs forbidden errors when it attempts the creation. What is the most likely cause?
- ANetworkPolicy is not a valid Kubernetes resource kind, so the API server refuses to create any object of that type in the cluster
- BGenerate rules can only create ConfigMaps, so a NetworkPolicy has to be written by hand in each Namespace
- CThe admission webhook is in Audit mode, which blocks every write made by controllers in the cluster
- DThe service account used by the Kyverno controller lacks RBAC permission to create NetworkPolicy resources
Show answer and explanationHide answer
Correct answer: DA forbidden error points to RBAC, so the Kyverno controller's service account must be granted permission to create the target kind. NetworkPolicy is a valid kind, generate rules are not limited to ConfigMaps, and Audit mode reports violations rather than blocking controller writes.
Question 14
A company runs several admission controller replicas for Kyverno. What is the main benefit of this setup?
- AIf one replica is unavailable, the other replicas can still answer admission webhook requests
- BEach replica keeps its own copy of the policies, so policies cannot be lost during an upgrade
- CExtra replicas split the cluster into shards, so background scans finish faster on large clusters
- DExtra replicas remove the need for the Kubernetes API server to call webhooks during requests
Show answer and explanationHide answer
Correct answer: AAdmission requests are sent to the webhook service, so with several replicas one failed Pod does not stop admission decisions. Policies are stored as cluster objects rather than inside each replica, replicas do not shard background scans, and the API server must still call the webhook.
Question 15
A new cluster operator wants to install Kyverno with the official Helm chart. Before `helm install kyverno kyverno/kyverno` can resolve the chart name, what must be done?
- AAdd the Kyverno chart repository with helm repo add and refresh the index
- BRun kyverno apply with the chart name so that the CLI registers the chart repository
- CCreate the ClusterPolicy CRDs by hand, because Helm cannot resolve chart names without them
- DInstall the kube-scheduler plugin that ships with Kyverno so Helm can locate charts
Show answer and explanationHide answer
Correct answer: AThe kyverno/kyverno chart name resolves only after the chart repository has been added with helm repo add (pointing at the Kyverno project's chart repository) and refreshed with helm repo update. The Kyverno CLI does not manage Helm repositories, Helm does not need hand-made CRDs to find a chart, and there is no scheduler plugin involved.
Kyverno CLI (5 questions)
Question 16
A developer wants to check, in a CI job, whether manifests in a Git branch would violate policies stored as files. The CI runner has no access to the cluster. Which Kyverno CLI command fits?
- Akyverno test, which deploys the manifests into a temporary Namespace on the cluster
- Bkyverno version, which compares the policy files with the controller version installed in the cluster
- Ckyverno jp, given the manifest files as the input for a JMESPath query
- Dkyverno apply, given the policy files and the manifest files as inputs
Show answer and explanationHide answer
Correct answer: Dkyverno apply evaluates policies against resource files offline and reports the results, so no cluster is needed. kyverno jp only evaluates JMESPath expressions, kyverno test checks results against expectations in a test file rather than deploying anything, and kyverno version only reports the CLI version.
Question 17
What does the kyverno-test.yaml file do when it is used with the Kyverno CLI test command?
- AIt installs the policy into the cluster with the admission settings written in the file, so that it is active immediately after kubectl runs
- BIt stores the private key used to sign images that verifyImages rules check against
- CIt declares which resources should pass or fail each policy rule, so kyverno test can compare the actual results with them
- DIt keeps a history of PolicyReport results that the background controller has produced over time
Show answer and explanationHide answer
Correct answer: CA Kyverno test file maps resources and policies to expected results, and kyverno test compares the actual outcomes with those expectations. The file does not install anything, hold signing keys, or store report history.
Question 18
A policy author wants to try a JMESPath expression against a sample JSON document before putting it into a rule. Which Kyverno CLI subcommand is built for this?
- Ajp, which evaluates JMESPath expressions against an input document
- Bapply, which evaluates expressions inside a live admission webhook for the cluster
- Ctest, which runs the policy against an empty cluster and prints the outcome
- Dversion, which prints the versions of the JMESPath libraries that the CLI uses
Show answer and explanationHide answer
Correct answer: AThe jp subcommand works as a JMESPath playground in the terminal, so an author can check a query before embedding it in a rule. The other subcommands run policies or report versions, and none of them evaluates an arbitrary expression for the author.
Question 19
Which two methods are valid ways to install the Kyverno CLI on a developer workstation? (Choose two.)
- ACopy the Kyverno admission controller image into /usr/local/bin
- BInstall it with Homebrew
- CDownload a release binary from the Kyverno project's GitHub releases
- DRun helm install kyverno-cli to create a Deployment on the cluster
Show answer and explanationHide answer
Correct answer: B, CHomebrew and the binaries published on the project's GitHub releases are standard ways to put the CLI on a workstation. Helm installs workloads into a cluster rather than a CLI on a laptop, and an admission controller container image is not an executable CLI.
Question 20
A developer wants to see what a mutate policy would change in a folder of Deployment manifests, with the patched manifests printed for review and without touching the cluster. Which command fits?
- Akyverno test with an empty test file, which prints every field that the mutate rule would change in each manifest and the reason for each change
- Bkyverno apply, given the policy and the folder, which prints the resources after the mutate rules have been applied to them
- Ckyverno version, which lists the patches that each policy would apply to the Deployments found in the folder
- Dkyverno jp parse, given the folder, which rewrites each manifest in place with the patch that the policy would apply
Show answer and explanationHide answer
Correct answer: Bkyverno apply runs policies against resource files offline and outputs the mutated resources together with the results. The jp subcommand evaluates queries rather than patching files, an empty test file does not describe changes, and the version subcommand only prints the CLI version.
Applying Policies (5 questions)
Question 21
An administrator adds a new validation policy to a cluster that already runs many workloads. They want to know which existing Pods violate the policy without waiting for those Pods to be recreated. What should they use?
- AThe Kyverno CLI test command, which connects to the cluster and rewrites the running Pods
- BThe background scan, which evaluates existing resources and records the results in policy reports
- CA cleanup policy, which deletes every existing Pod that does not match the new policy
- DThe admission webhook, which re-checks every running Pod each time the scheduler places a new Pod on a node in the cluster
Show answer and explanationHide answer
Correct answer: BBackground scanning evaluates resources that already exist, and the results appear in policy reports. Admission webhooks only see requests as they arrive, the test command works on local files rather than the live cluster, and a cleanup policy deletes resources instead of reporting on them.
Question 22
A policy should apply to Deployments in the payments Namespace, except those labelled tier set to test. Which part of the rule handles this selection?
- AA match block that selects Deployments in the payments Namespace, plus an exclude block that skips resources labelled tier=test
- BA validationFailureAction set to Audit for every Deployment in the cluster, so that violations are reported but never blocked anywhere
- CA generate block with a cloneList entry that points at the payments Namespace and creates copies of Deployments in that Namespace
- DA mutate block that adds a tier annotation to every Deployment in the cluster, which changes the objects that are stored
Show answer and explanationHide answer
Correct answer: AThe match and exclude blocks decide which resources a rule evaluates, so they handle Namespace and label selection. The other options change the object, change the reporting mode for all Deployments, or create resources, and none of them selects resources.
Question 23
A rule should run only for Pods that have more than one container, a condition that depends on the incoming object. Which rule setting expresses this?
- AThe exclude block, which lists the container counts that the rule should skip
- BThe background field, which turns a rule into an audit-only check that scans existing resources but never blocks any request
- Cpreconditions, which are evaluated before the rule's checks, so the rule runs only when they hold
- DThe failurePolicy field, which sets how the rule handles containers that are missing
Show answer and explanationHide answer
Correct answer: CPreconditions are conditions evaluated before a rule's checks and can use values such as the number of containers. The background field controls whether existing resources are scanned, exclude lists resources to skip rather than counts, and failurePolicy is a webhook setting rather than a rule field.
Question 24
A new policy would block some legacy workloads that the team is not yet ready to change. The team wants violations recorded in policy reports during a rollout period, while no request is rejected. Which setting should the policy use during this period?
- AA mutate rule that quietly patches each legacy workload so that it passes the check before it is admitted to the cluster
- BA PolicyException that covers the whole cluster, so that no workload is ever evaluated by the rule during the rollout
- CvalidationFailureAction set to Enforce, which rejects the legacy requests that fail the check and records each rejection
- DvalidationFailureAction set to Audit, so violations are reported and the requests are still admitted to the cluster
Show answer and explanationHide answer
Correct answer: DAudit mode admits the request and records the violation, which suits a rollout period. Enforce would reject the legacy requests, a mutate rule changes workloads rather than reporting on them, and a cluster-wide exception would stop the rule from reporting anything at all.
Question 25
Which two fields help control which resources a Kyverno rule evaluates? (Choose two.)
- AThe exclude block, which removes resources from the rule's scope when they meet the criteria it lists
- BThe message field, which sets the text that is shown to the user when the rule fails for a resource
- CThe synchronize field, which keeps generated resources in step with the source resources they were built from
- DThe match block, which selects resources by kind, Namespace, name, labels, or the subjects making the request
Show answer and explanationHide answer
Correct answer: A, DThe match and exclude blocks define the scope of a rule, deciding which resources are checked and which are skipped. The message field only sets the text shown on failure, and synchronize applies to generate rules, so neither one limits which resources a rule evaluates.
Policy Management (5 questions)
Question 26
A security lead wants to see, per Namespace, how many resources passed or failed each policy rule, without reading admission logs. Which Kyverno output provides this?
- APolicyReport resources, which are generated per Namespace and list the results for each rule
- BCleanupPolicy resources that count how many resources they removed each day
- CConfigMap objects that Kyverno fills with raw audit log lines for each admission request
- DPolicyException resources, which list every failed resource in each Namespace together with the rule that it broke
Show answer and explanationHide answer
Correct answer: AThe reports controller writes PolicyReport resources that contain per-rule results, and namespaced reports are grouped by Namespace. PolicyException resources exempt resources rather than reporting failures, and the other two options do not produce compliance summaries.
Question 27
Which two statements about PolicyException resources in Kyverno are correct? (Choose two.)
- AThey select resources with match-style criteria, so one exception can cover a group of objects
- BThey switch every enforced rule in the cluster to Audit mode until the exception is removed
- CThey are stored inside each PolicyReport, so users cannot create them directly
- DThey exempt matching resources from named rules in an existing policy without editing that policy
Show answer and explanationHide answer
Correct answer: A, DA PolicyException names the policy and rules it exempts and selects matching resources, leaving the policy itself unchanged. Exceptions do not switch enforcement modes cluster-wide, and they are ordinary resources that users create rather than entries inside reports.
Question 28
A cluster administrator wants one view of background scan results for policies that apply to cluster-scoped resources such as Namespaces. Which report resource holds these results?
- AClusterPolicyReport, which holds results for cluster-scoped resources and cluster-wide policy checks
- BCleanupPolicy, which stores the names of the cluster-scoped resources that it removed during each scheduled run
- CA PolicyReport in the default Namespace, which holds the results for every Namespace in the cluster in one place
- DPolicyException, which lists the cluster-scoped resources that are currently exempt from the policies in the cluster
Show answer and explanationHide answer
Correct answer: AClusterPolicyReport is the cluster-scoped counterpart to PolicyReport, and it carries results for cluster-scoped resources. A namespaced PolicyReport only covers resources in its own Namespace, while PolicyException and CleanupPolicy do not store scan results.
Question 29
A legacy Deployment in the legacy Namespace must keep using a hostPath volume. A cluster-wide policy blocks hostPath for every other workload, and the team wants the exemption limited to that one Deployment. Which resource expresses this?
- AAn annotation on the legacy Namespace that switches off every Kyverno policy for all workloads running inside that Namespace
- BA cleanup policy that deletes the legacy Deployment after one week, so that the hostPath volume is removed from the cluster
- CA second ClusterPolicy set to Audit mode for every Deployment in the cluster, so that the hostPath check no longer blocks anything
- DA PolicyException that names the policy and rule and matches only that one Deployment in the legacy Namespace
Show answer and explanationHide answer
Correct answer: DA PolicyException can reference a specific policy and rule and select a single resource, so the rest of the cluster stays enforced. Audit mode for every Deployment removes enforcement for all workloads, an annotation on a Namespace is not a documented way to disable policies, and cleanup would delete the workload that the team needs to keep.
Question 30
A platform team wants dashboards and alerts on how often Kyverno's policies produce results and admission decisions. Which kind of data does Kyverno provide for this purpose?
- AA full copy of each admitted manifest, which is written to a file on every node for later auditing purposes
- BThe private keys used to sign container images, which are published as metrics so that dashboards can verify each signature
- CHelm values for each release, which are exported as time series so that upgrades can be compared over time
- DPrometheus metrics that count policy results and admission requests, which can be graphed and used in alerts
Show answer and explanationHide answer
Correct answer: DKyverno exposes Prometheus metrics, including counts of policy results and admission requests, which suit dashboards and alerts. Manifest copies, signing keys, and Helm values are not what the metrics endpoint publishes.