<p>We are trying to replace our existing PSPs in kubernetes with OPA policies using Gatekeeper. I'm using the default templates provided by Gatekeeper <a href="https://github.com/open-policy-agent/gatekeeper-library/tree/master/library/pod-security-policy" rel="nofollow noreferrer">https://github.com/open-policy-agent/gatekeeper-library/tree/master/library/pod-security-policy</a> and defined corresponding constraints.</p>
<p>However, I can't figure out how I can apply a policy to a specific <code>ServiceAccount</code>.
For eg. how to define <code>allow-privilege-escalation</code> policy only to a ServiceAccount named awsnode?</p>
<p>In PSPs I create a Role/ClusterRole for required <code>podsecuritypolicies</code> and create a RoleBinding to allow awsnode ServiceAccount to use required PSP. I'm struggling to understand how to achieve the same using Gatekeeper OPA policies?</p>
<p>Thank you.</p>

autobot
<p>Apparently PSPs and Gatekeeper OPA policies are designed to achieve pod security at different levels. Here is the response from AWS support on the above question.</p>
<p>Gatekeeper constraint templates (and the corresponding constraint CRDs defined from the templates) apply to a larger scope of Kubernetes resources than just pods. Gatekeeper extends additional functionality that RBAC cannot provide at this stage.
Gatekeeper itself cannot be managed by RBAC (by means of using verbs to restrict access to Gatekeeper constraints), because no RBAC resource keyword exists for Gatekeeper policy constraints (at least, at the time of writing this).
PodSecurity Admission Controller might be an option for someone looking for a replacement for PSPs which needs to be controlled by RBAC if the cluster is on 1.22 version or above.</p>
