Currently, when a pod is created with the security.rancher.io/policy label referencing a WorkloadPolicy that doesn't exist, the pod is allowed to start and an error is logged (internal/nri/plugin.go:176-179). This means the pod runs without any runtime protection silently.
We should add a new VAP/validating admission webhook that checks, at pod CREATE time, whether the WorkloadPolicy referenced in the security.rancher.io/policy label actually exists in the cluster. If the policy does not exist, the pod creation should be denied with a clear error message.
This will work alongside a future NRI-level enforcement (see #392) that blocks container startup until the policy is reconciled by the agent.
Acceptance Criteria
Currently, when a pod is created with the
security.rancher.io/policylabel referencing aWorkloadPolicythat doesn't exist, the pod is allowed to start and an error is logged (internal/nri/plugin.go:176-179). This means the pod runs without any runtime protection silently.We should add a new VAP/validating admission webhook that checks, at pod CREATE time, whether the WorkloadPolicy referenced in the security.rancher.io/policy label actually exists in the cluster. If the policy does not exist, the pod creation should be denied with a clear error message.
This will work alongside a future NRI-level enforcement (see #392) that blocks container startup until the policy is reconciled by the agent.
Acceptance Criteria