Policy Controller adds organization-specific guardrails to Kubernetes clusters managed with Anthos Config Management (ACM). Role-based access control determines who may act on types of resources; Policy Controller can enforce conditions on the resources themselves, such as requiring CPU limits on Pods or a cost-center label on Namespaces. It can also address conditions formerly handled by deprecated Pod Security Policies. section 2.8 section 11.2.3 section 13.3.1
Enabling the policy engine registers a validating webhook with the Kubernetes API server. For an object request, the API server calls the Gatekeeper service; a Gatekeeper Pod checks the configured policies. A denial prevents the object from being created and returns the policy error. Constraint templates and constraints supply the policy logic. section 13.4.1
Trace a Pod creation request through the API server, Gatekeeper, and the admission decision. section 13.4.1
A practical rollout separates policy scope from enforcement:
- Choose a constraint template and define a constraint that matches the intended resource kinds. Examples include rejecting privileged containers, requiring a billing label on Namespaces, and requiring container image digests on Pods. section 13.4.1
- Use `enforcementAction: dryrun` to inspect reported violations before enforcing a constraint. A privileged-container example reports violations in system Pods, illustrating why scope matters. section 13.4.1
- Configure namespace exemptions deliberately: audit, webhook, and sync exemptions affect different Gatekeeper processes; `*` excludes a namespace from all three. An unauthorized attempt to add the ignore label is denied. section 13.4.1
Require a billing label
A `K8sRequiredLabels` constraint can match Namespace objects and require a `billing` label. When admission enforcement applies, a request without the label receives a denial identifying the missing label. section 13.4.1
Policy checks add work to admission. The cited average is about one millisecond per evaluation, but a costly custom policy can increase overall latency. Test policies and exemptions against the resources they will affect. ACM policies used alongside service-mesh configuration may also reach every cluster managed by an external repository unless a ClusterSelector narrows their scope. section 13.4.1 section 13.7
