Completed Is Not Restored: Kyverno Fail-Open, a Velero Restore and an HTTP 200 That Meant 500
By Vladimir Mikhalev Docker Captain · CNCF Ambassador · IBM Champion
Set Kyverno’s admission controller to zero replicas in a Kubernetes cluster and every webhook configuration it manages is deleted on the way down. Kyverno 1.19 does this on purpose, and 1.20, released on 12 November, keeps the same check line for line: its webhook server checks whether its own Deployment is being deleted or scaled to zero, and if it is, removes every validating and mutating webhook it registered. From that moment the API server admits whatever Kyverno would have refused, and nothing anywhere reports an error. It is not new. An issue opened in March 2023, against Kyverno 1.9, asked for the webhooks to stay; the maintainers’ answer was that scaling Kyverno to zero is a privileged act, like deleting it. The daily suite of a Kubernetes reference platform I run on kind hit it in the same month as a Velero restore that said Completed over an empty disk and a backend that answered HTTP 200 to say a file was missing.
Three components, three statuses, each one true about the component’s own work and false about the thing I cared about. A status is a component’s account of what it did. It is not a measurement of the outcome. Every one of these three was caught only because a check read the outcome directly: a manifest that had to be refused, a marker that had to come back, a response body that had to say what happened. The same shape, a number honest about itself and wrong about the fleet, is in a partial read published as the whole.
What three green statuses look like
The platform is a reference build: Argo CD ApplicationSets, Kyverno for admission, Velero for backups, a demo tenant that keeps data on a volume, and an end-to-end suite that has run on kind every day since 14 October. The same platform was first applied, checked and torn down on a real AWS account on 15 October 2026, and a weekly run on that account has been scheduled since 21 October. Each of the three findings below came out of an automated run on kind, and each one changed what those runs check.
Kyverno admission that refuses nothing
The decision lives in two functions in Kyverno’s source, at its 1.19 release tag:
// kyverno v1.19.1, pkg/utils/runtime/utils.gofunc (c *runtime) IsGoingDown() bool { if c.IsDebug() { return false } deployment, err := c.getDeployment() if err != nil { return apierrors.IsNotFound(err) } if deployment.GetDeletionTimestamp() != nil { return true } if deployment.Spec.Replicas != nil { return *deployment.Spec.Replicas == 0 } // ...}
// kyverno v1.19.1 (the same at v1.20.0), pkg/webhooks/server.go, shortenedfunc (s *server) cleanup(ctx context.Context) { if s.runtime.IsGoingDown() { // ... deleteLease, for Kyverno's two leases deleteVwc := func() { if err := s.vwcClient.DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{ LabelSelector: kyverno.LabelWebhookManagedBy, }); err != nil && !apierrors.IsNotFound(err) { // ... the error is logged } } // ... deleteMwc, the same for mutating webhook configurations deleteLease("kyvernopre-lock") deleteLease("kyverno-health") deleteVwc() deleteMwc() // ...A policy enforced only through those webhooks is enforced only while Kyverno is up and has not been scaled down. A node failure that kills the pods leaves the webhooks in place, and Kyverno’s own troubleshooting page describes that opposite case, an API server timing out on a webhook nobody answers. A deliberate scale to zero replicas, the move an on-call engineer makes when the admission controller is the suspect, takes the other path. Admission opens, silently.
The fix is to stop depending on the webhook for the rules that matter. Kubernetes has evaluated admission policies in-process since ValidatingAdmissionPolicy went stable in 1.30, and Kyverno 1.19 can compile its ValidatingPolicy into one:
# policies/require-image-digest.yaml in aws-eks-reference-platform at v1.2.0,# shortened: the apps and batch resource rules are left out# A tag can be moved to different bytes after the image was reviewed; a digest# cannot. Pods, and the Deployments, StatefulSets, DaemonSets, Jobs and# CronJobs that make them, are refused unless every container image is# referenced by digest.apiVersion: policies.kyverno.io/v1kind: ValidatingPolicymetadata: name: require-image-digest annotations: policies.kyverno.io/description: Every container image in a tenant namespace is referenced by digest.spec: validationActions: [Deny] failurePolicy: Fail # Kyverno compiles this into a ValidatingAdmissionPolicy that the API server # enforces itself. A Kyverno outage removes Kyverno's webhooks (tests/e2e # proves it); it does not remove this. autogen: validatingAdmissionPolicy: enabled: true matchConstraints: namespaceSelector: matchLabels: platform.heyvaldemar.com/tenant: "true" resourceRules: - apiGroups: [""] apiVersions: [v1] operations: [CREATE, UPDATE] resources: [pods] # ... the apps and batch rules: deployments, statefulsets, daemonsets, jobs, cronjobs variables: # One expression for a Pod and for everything that makes Pods, written # out rather than left to Kyverno's autogen: autogen would rule out the # native ValidatingAdmissionPolicy below. - name: podSpec expression: >- object.kind == 'Pod' ? object.spec : object.kind == 'CronJob' ? object.spec.jobTemplate.spec.template.spec : object.spec.template.spec - name: containers expression: >- variables.podSpec.containers + (has(variables.podSpec.initContainers) ? variables.podSpec.initContainers : []) + (has(variables.podSpec.ephemeralContainers) ? variables.podSpec.ephemeralContainers : []) validations: - expression: variables.containers.all(c, c.image.contains('@sha256:')) message: >- every image must be referenced by digest (repository:tag@sha256:...); a tag alone can point at different bytes tomorrowKyverno’s documentation names the price: generating a ValidatingAdmissionPolicy and auto-generating rules for pod controllers are mutually exclusive, because the API server cannot run Kyverno’s controller variants. The platform’s policies cover Deployments, StatefulSets, DaemonSets, Jobs and CronJobs with the podSpec variable above instead.
The failure policy on that file is a decision, not a default. Since Kyverno 1.20 a ValidatingPolicy that says Ignore also admits a request when its own evaluation fails at runtime. The platform’s policies say Fail.
The proof is a step in the daily run that does what the on-call engineer would do and then tries five manifests that must be refused:
# tests/e2e/run.sh in aws-eks-reference-platform at v1.2.0, shortened:# step 4b, and the plants function it shares with step 4plants() { # plants <label>: every plant refused as expected, the control admitted local plant name expect out rc for plant in "$HERE"/plants/*.yaml; do name="$(basename "$plant" .yaml)" expect="$(sed -n 's/^# expect: //p' "$plant")" out="$(kubectl apply --dry-run=server -f "$plant" 2>&1)" rc=$? if [ "$expect" = admitted ]; then if [ $rc -eq 0 ]; then pass "$1$name: admitted"; else fail "$1$name was refused: $out"; fi elif [ $rc -ne 0 ] && grep -q "$expect" <<<"$out"; then pass "$1$name: refused by $expect" else fail "$1$name: expected a refusal by '$expect', got (rc=$rc): $out" fi done}
plants ""
step "4b. the same refusals with Kyverno's admission controller stopped"# ... each Kyverno policy must have its compiled ValidatingAdmissionPolicykubectl -n argocd patch application kyverno --type merge -p '{"spec":{"syncPolicy":{"automated":null}}}' >/dev/nullkubectl -n kyverno scale deployment kyverno-admission-controller --replicas=0 >/dev/nullkubectl -n kyverno wait --for=delete pod -l app.kubernetes.io/component=admission-controller --timeout=180s >/dev/null 2>&1if kubectl get validatingwebhookconfiguration kyverno-resource-validating-webhook-cfg >/dev/null 2>&1; then echo " (Kyverno's resource webhook is still registered)"else echo " (Kyverno removed its resource webhook when it stopped)"fiplants "Kyverno down: "# ... auto-sync back on, and Argo CD must bring the admission controller back from zeroThe runs log that Kyverno removed its webhook, then five refusals anyway: four by the generated admission policies, one by Pod Security. A compliant pod in the same set is admitted, so the refusals are not the cluster refusing everything. In the environment I run today and in every one before it, the controls I trusted least were the ones that only existed while a single process was healthy.
A Velero restore that says Completed
Velero’s file-system backup copies a pod’s volumes file by file, and its documentation states the limit in one line: hostPath volumes are not supported, local persistent volumes are. kind’s default StorageClass, standard, is served by the local-path provisioner, and the provisioner creates a hostPath volume unless the class or the claim asks for local.
So the backup on kind’s defaults copied nothing, finished Completed, and the restore that followed finished Completed too, with the pod running on an empty disk. The fix is one annotation on the platform’s own StorageClass:
# manifests/overlays/kind/storageclass.yaml in aws-eks-reference-platform at# v1.2.0# kind's default class hands out hostPath volumes, and Velero's file-system# backup skips hostPath volumes without failing the backup: the restore then# brings back an empty disk. The same provisioner, told to make `local`# volumes, gives Velero something it can back up. Workloads whose data must# survive a restore on kind ask for this class (apps/demo/overlays/kind).apiVersion: storage.k8s.io/v1kind: StorageClassmetadata: name: kind-local annotations: defaultVolumeType: localprovisioner: rancher.io/local-pathvolumeBindingMode: WaitForFirstConsumerreclaimPolicy: DeleteAnd a check that does not ask Velero how it went. Before the restore it counts what the backup copied; after, it reads back a marker written through the Gateway before the incident:
# the two reads, condensed from tests/e2e/run.sh in aws-eks-reference-platform at v1.2.0kubectl -n velero get podvolumebackups -l velero.io/backup-name="$name" -o name | wc -l # 0 means no volume was copiedcurl -s --cacert ca.crt "https://demo.platform.test:28443/store/$hash" # must print the markerAn HTTP 200 that carries a 500
The hands-on guide that ships with the platform makes the reader break a restore on purpose: back up once with volumes and once without, delete the namespace, restore from the wrong one, and see the data gone. The script that runs the guide every week failed that step: it expected HTTP 500 for the missing file and got 200.
The first cause I put on record, in a commit message, was wrong. My explanation was a restore that had found the old disk before the provisioner cleaned it up. Velero’s restore code, unchanged in 1.19, says otherwise: a persistent volume with a Delete reclaim policy and no copied data is provisioned fresh, under a new name and a new directory. The backend had answered correctly the whole time. The demo runs podinfo, and podinfo reports every handler error like this:
// podinfo 6.15.0, pkg/api/http/http.gofunc (s *Server) ErrorResponse(w http.ResponseWriter, r *http.Request, span trace.Span, error string, code int) { // ... marshals {"code": code, "message": error} w.WriteHeader(http.StatusOK) w.Write(prettyJSON(body))}{ "code": 500, "message": "reading file failed"}That body, a JSON object with code 500, arrives with HTTP status 200. A file it can read comes back with 202. The check that expected 500 could never have passed. It reads the body now, and the guide tells the reader why.
Why this keeps happening
Every status in this post is a component reporting on the task it was given, and each task was narrower than the outcome. Velero was asked to copy the volumes its file-system backup supports, and it did. Kyverno’s shutdown path was written to keep a cluster available when its admission controller is gone, which is a defensible choice; it trades a cluster-wide outage for a quiet gap in enforcement. podinfo is a demo application that chose to put errors in its response body. None of the three is a bug in the component. Each is a default that a status hides from whoever reads only the status. It is the health check that cannot fail, moved from one container to the whole cluster.
The second reason is where the check lives. Backup tooling, admission controllers and load balancers all expose a status that dashboards can read cheaply: a phase, a ready condition, a response code. Reading the outcome costs more. It means writing a marker, deleting a namespace, waiting for a restore and reading the marker back; it means scaling a controller to zero in a test cluster and proving a refusal still happens. That cost is why the cheap signal ends up as the only signal.
The third reason is that my first diagnosis of the 200 was also a status read: I saw a code, matched it to a cause that sounded right, and wrote it down. Reading the source of the two components involved took twenty minutes and replaced the story with a fact.
Risk and blast radius
Admission that opens during an incident does not close behind itself. A ValidatingAdmissionPolicy or a Kyverno webhook judges a request at create or update time, so anything admitted while the webhook was gone stays in the cluster after Kyverno comes back: a privileged pod, an image pinned by tag, a workload without limits. Kyverno’s background scans report such resources; they do not remove them. If the only record of what was admitted is the API server’s audit log, someone has to go and read it.
The switch is also small. Anyone who can change the replica count of that one Deployment can turn admission off: a person with edit rights in Kyverno’s namespace, or a commit to the repository a GitOps controller applies. What follows is an ordinary API call by Kyverno’s own service account, a delete of the webhook configurations it manages, and Kyverno’s log records it as a successful cleanup. Where the API server’s audit policy records webhook configurations, that one event is the cheapest alarm this failure has.
A restore that reports success over an empty disk is found during the incident it was meant to end. Every backup before it reported Completed too, so the retention window does not help: the last good copy is the last one taken before the volume type changed, and nobody knows when that was.
The HTTP status is the quietest of the three, and it reaches furthest. The demo’s availability objective counts responses with a server error status, 500 to 599, the way most service level objectives do, so a reading file failed in a 200 counts as a success. The objective cannot see that failure at all. A real service has to return the status it means, or its error budget measures something else.
Framework: check the effect, never the status
Each layer below names the check, the command and who owns it. Together they replace three status reads with three outcome reads.
Layer 1: admission that survives its own controller (week 1)
List what is enforced by a webhook alone. Any ValidatingPolicy without a generated ValidatingAdmissionPolicy is on that list.
# kubectl: policies the API server enforces natively,# against all Kyverno validating policieskubectl get validatingadmissionpolicies -o name | sed 's#.*/vpol-##' | sort > native.txtkubectl get validatingpolicies.policies.kyverno.io -o name | sed 's#.*/##' | sort > all.txtcomm -13 native.txt all.txt # webhook-only: these stop when Kyverno is scaled to zeroMove each one to autogen.validatingAdmissionPolicy.enabled: true, or write down why it cannot move (mutation and generation still need Kyverno).
Image verification cannot move either: the API server has no way to check a signature. For a check like that, make Kyverno’s absence the refusal. A second repository of mine, an AI agent with no route out of its cluster, found the need the hard way. Its daily game day scales Kyverno’s admission controller to zero while a model is being served. On the second such run, seven webhook configurations became two, and the API server admitted a model nobody had signed and another signed under a licence the site does not allow. The run before it, cancelled before its other jobs finished, had kept all seven in its game-day job, only because Kyverno reads its own Deployment from a cache that had not caught up yet. A drill that passes once has proved nothing about the second time.
The fix, released in version 1.6, is a native policy whose parameter is Kyverno’s own webhook configuration:
# admission/kyverno-guard.yaml in kubernetes-air-gapped-ai-agent at v1.6.0,# shortened:# a pod that mounts a model is admitted only while Kyverno's webhook for verify-models exists and fails closedapiVersion: admissionregistration.k8s.io/v1kind: ValidatingAdmissionPolicymetadata: name: models-need-kyvernospec: failurePolicy: Fail paramKind: apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration # ... matched to pods in namespaces labelled for verified models matchConditions: - name: mounts-an-image expression: object.spec.?volumes.orValue([]).exists(v, has(v.image)) validations: - expression: >- params.webhooks.exists(w, w.name == 'ivpol.validate.kyverno.svc-fail-finegrained-verify-models' && w.failurePolicy == 'Fail') message: no model is mounted while Kyverno is not there to verify it (its webhook for verify-models is missing)---apiVersion: admissionregistration.k8s.io/v1kind: ValidatingAdmissionPolicyBindingmetadata: name: models-need-kyvernospec: policyName: models-need-kyverno validationActions: [Deny] paramRef: name: kyverno-resource-validating-webhook-cfg parameterNotFoundAction: DenyWith it, the same game day refuses all three models, the signed one included, and the model already being served keeps answering. Once Kyverno is back, the signed model is admitted again thirty-one seconds later. While the checker is away, no new model starts at all. That is an outage. It is not a hole.
Owner: the platform engineer who owns admission policy.
Layer 2: a backup is the data it holds (week 2)
For every StorageClass a backed-up namespace uses, confirm the volume type Velero’s file-system backup can read, then count what each backup copied:
# local-path: hostPath unless the class or claim says localkubectl get storageclass -o custom-columns=NAME:.metadata.name,PROVISIONER:.provisioner,TYPE:.metadata.annotations.defaultVolumeType# per backup: one PodVolumeBackup per volume, or the volume was not copiedkubectl -n velero get podvolumebackups -l velero.io/backup-name=<backup> -o custom-columns=VOLUME:.spec.volume,PHASE:.status.phaseIt is the rule from the restore drill on a clean machine, one level down: a backup counts once its data has come back.
Owner: whoever owns the backup schedule, usually the SRE on the platform team.
Layer 3: a daily drill that reads outcomes (week 3 onward)
A scheduled job in a disposable cluster does the three things a status cannot: scales the admission controller to zero and requires the refusals, restores a deleted namespace and reads back a marker, and checks response bodies where the application puts its errors.
# .github/workflows/kind-e2e.yml in aws-eks-reference-platform at v1.2.0,# shortenedon: push: branches: [main] # ... pull requests that change more than documentation schedule: - cron: "41 4 * * *" workflow_dispatch:# ... permissions and concurrencyjobs: e2e: name: Fresh install, every check runs-on: ubuntu-latest timeout-minutes: 45 steps: # ... checkout, and the pinned tools - name: Create the kind cluster run: kind create cluster --config kind/cluster.yaml --wait 120s
- name: Bootstrap Argo CD at this commit # ... env: the repository URL and the commit under test run: ./bootstrap/bootstrap.sh kind
- name: Wait for every Application to be Synced and Healthy run: | python3 scripts/render.py kind out/kind >/dev/null EXPECTED_APPS="$(python3 -c 'import yaml; print(" ".join(a["metadata"]["name"] for a in yaml.safe_load_all(open("out/kind/_applications.yaml")) if a))')" \ ./scripts/wait-for-platform.sh 1500
- name: Run the checks # ... env: where the results are written run: ./tests/e2e/run.sh # ... the results are kept, and a failed run prints what the cluster looked likeOwner: the platform team, with the failing step named in the run’s summary so the on-call engineer does not have to read the log to know which promise broke.
Tradeoffs
Native admission policies cost expressiveness. CEL in a ValidatingAdmissionPolicy validates; it does not mutate or generate, the only objects it can read beyond the request are its one parameter and the request’s namespace, and Kyverno’s controller auto-generation is off the table once the policy compiles to native. The platform keeps Kyverno for generation, a default-deny NetworkPolicy per tenant, and accepts that the generator stops while Kyverno does.
The drills cost time and minutes. The daily kind run takes about fifteen minutes on a GitHub-hosted runner, most of it bringing the platform up; the restore drill alone is a few minutes. That is the price of a restore that has been proven this week, against a restore that has been reported every night.
Reading bodies costs coupling. A check that parses podinfo’s error JSON knows podinfo’s error format, and breaks when it changes. That is the right failure: a check that breaks loudly when the application changes how it reports errors, instead of one that passes quietly because the status code never changed.
The closing argument
A status is the component’s account of its own work, and all three of these were accurate accounts. Kyverno did shut down cleanly. Velero did copy every volume it supports. podinfo did answer. None of that said whether the cluster was enforcing, whether the data was there, or whether the request had worked. The checks that caught them read the outcome, and they cost a test cluster, twenty minutes a day and a parser for one error format. Not having them costs nothing until the morning a restore is needed.
Sources
- Kyverno, source of the shutdown check at the 1.19 release (going down means deleted, or scaled to zero replicas)
- Kyverno, source of the webhook server at the 1.19 release (webhook configurations deleted on shutdown when going down)
- Kyverno, Issue 6554: Webhooks are removed when Kyverno deployment scaled to zero, March 2023 (reported against 1.9, closed as completed on 25 May 2023; the behaviour is still in the source at 1.20)
- Kyverno, ValidatingPolicy (
autogen.validatingAdmissionPolicy, mutually exclusive with pod controller auto-generation), accessed November 2026 - Kyverno, Troubleshooting, API server is blocked (the fail-closed case when all Kyverno pods are down), accessed November 2026
- Kubernetes, Validating Admission Policy (stable since version 1.30, evaluated in-process), accessed October 2026
- Velero, File System Backup (hostPath volumes are not supported, local persistent volumes are), accessed November 2026
- Velero, source of the restore logic at the 1.18 release (a PV with a Delete reclaim policy and no copied data is re-provisioned; the same in 1.19)
- Rancher, local-path-provisioner README (
defaultVolumeType, hostPath by default) - kind, source of the default storage class at the 0.33 release (the default
standardclass, served by local-path) - podinfo, source of the HTTP error response at the 6.15 release (its error response writes HTTP 200)
- heyvaldemar, aws-eks-reference-platform (the e2e suite, the hands-on guide and the restore runbook)
Discussion
If you have scaled an admission controller to zero during an incident, or trust a backup because a status said so, drop a comment below. Counterarguments are welcome and the comment thread is where I respond first.