Page MenuHomePhabricator

[k8s,infra] Verify that kyverno policies are evaluated only for namespaced resources
Closed, ResolvedPublic

Description

During the incident T367348: Incident: 2024-06-12 toolforge k8s control plane we had the theory that our kyverno policies (which are namespaced) could somehow be evaluated for resources outside their namespace, creating excessive load.

Given the amount of policies we have (3.5k policies with 2 rules each, total of 7k rules), this load could be exponential and fatal to the cluster.

Event Timeline

aborrero renamed this task from Verify that kyverno policies match our namespace to Verify that kyverno policies are evaluated only for namespaced resources.Thu, Jun 13, 9:03 AM
aborrero updated the task description. (Show Details)
aborrero changed the task status from Open to In Progress.Thu, Jun 13, 9:05 AM
aborrero triaged this task as High priority.
aborrero added a project: User-aborrero.

In the upstream docs:

Policies can be defined as cluster-wide resources (using the kind ClusterPolicy) or namespaced resources (using the kind Policy). As expected, namespaced policies will only apply to resources within the namespace in which they are defined while cluster-wide policies are applied to matching resources across all namespaces. Otherwise, there is no difference between the two types.

source: https://kyverno.io/docs/kyverno-policies/

With this information, the theory in this ticket loses some weight. But I'll keep the ticket open while I do additional research. I'm also considering to contact upstream about this theory.

dcaro renamed this task from Verify that kyverno policies are evaluated only for namespaced resources to [k8s,infra] Verify that kyverno policies are evaluated only for namespaced resources.Thu, Jun 13, 9:48 AM

None of my poking around have demonstrated that the upstream claim is false.