Interview Prep/DevSecOps/Kubernetes admission control and Pod Security

`kubectl apply --dry-run=server` passes, but the real apply is denied a minute later

AdvancedTroubleshootingKubernetes admission control and Pod Security
Answer

Likely causes → Webhooks marked sideEffects: Unknown/Some are skipped on dry-run, or the policy uses external data (image signature lookup, API calls, ConfigMap context) that changed or timed out.

Diagnose →

kubectl get validatingwebhookconfiguration -o jsonpath='{range .items[*]}{.metadata.name}{" "}{.webhooks[*].sideEffects}{"\n"}{end}'

Fix → Make webhooks declare sideEffects: None (and support dry-run), and stabilise external lookups (caching, timeouts).

Prevent → Treat dry-run as indicative, and rely on CI policy tests plus canary deploys.

All DevSecOps questions Roadmap: Policy as code

More on Kubernetes admission control and Pod Security