When adding or modifying security-sensitive API fields (including fields written by schedulers/kubelets or reflected in Pod/Container security context), enforce the full security invariant end-to-end:
1) Don’t trust status/snapshots from external writers
2) Validate transitions, not just the new object
3) Preserve security intent during merges
4) Align admission/policy with runtime behavior and be version-safe
Example pattern (transition validation sketch):
func ValidateXUpdate(newPod, oldPod *core.Pod, opts PodValidationOptions) field.ErrorList {
// Block or constrain security-relevant status changes after bind
if oldPod.Spec.NodeName != "" && newPod.Spec.NodeName != "" {
// Re-run coverage/limit checks or require the change to be non-increasing
// else return an error
}
// Validate bounds/shape of any status snapshots here
// (including explicit max sizes via a Go constant)
return nil
}
Apply this standard to any change involving security-context fields (e.g., cgroup options) or security-affecting status data used by scheduler/quota/kubelet calculations.