Operator RBAC
PGO runs under a dedicated ServiceAccount namedpgo. A ClusterRoleBinding connects that account to a ClusterRole named postgres-operator, granting it the permissions it needs to manage resources across any namespace.
ServiceAccount
ClusterRole summary
Thepostgres-operator ClusterRole grants PGO the ability to manage the following Kubernetes resources:
The
endpoints/restricted permission is required for OpenShift environments where the RestrictedEndpointsAdmission plugin blocks creating Endpoints that contain Pod IPs without explicit authorization.ClusterRoleBinding
Per-cluster instance RBAC
For each PostgresCluster, PGO creates a namespacedRole, RoleBinding, and ServiceAccount that are used by the PostgreSQL instance pods (primarily by Patroni, the high-availability manager).
What gets created
PGO calls these resources instance RBAC. They are all created in the same namespace as the PostgresCluster with a name derived from the cluster name. The ServiceAccount is configured withautomountServiceAccountToken: true so that Patroni can authenticate to the Kubernetes API.
Instance pod permissions
TheRole grants Patroni the permissions it needs to coordinate leader election and observe peer pods:
On OpenShift, an additional rule for
endpoints/restricted with the create verb is added automatically when spec.openshift: true is set (or auto-detected).
Viewing instance RBAC resources
Viewing operator RBAC resources
1
List the operator ClusterRole
2
Verify the ClusterRoleBinding
3
Confirm the operator ServiceAccount
Namespaced vs. cluster-scoped permissions
PGO uses cluster-scoped RBAC by default so it can manage PostgresCluster resources across multiple namespaces from a single operator deployment. The Kustomize configuration ships with acluster/ overlay that applies the ClusterRole and ClusterRoleBinding shown above.
If your environment requires namespace-scoped operator permissions, you will need to adapt the provided Kustomize overlays. A namespace/ directory exists in the config/rbac/ tree as a starting point, but namespaced deployments require additional configuration and may limit cross-namespace features.
OpenShift security context constraints
On OpenShift, PGO detects the environment automatically (or you can setspec.openshift: true explicitly on the PostgresCluster). When OpenShift mode is active, PGO:
- Adds the
endpoints/restrictedcreate verb to the instance pod Role so Patroni can register Pod IPs in Endpoints. - Expects that the Security Context Constraint (SCC) assigned to the instance ServiceAccount allows the containers to run with the UID and GID that the PostgreSQL image requires.
Related pages
- Installation with Kustomize — deploying PGO and applying the RBAC manifests
- Installation with Helm — Helm chart values that control RBAC resource creation
- Create a cluster — creating your first PostgresCluster after RBAC is in place
- PostgresCluster reference —
spec.openshiftand other spec fields