Skip to content

Commit 54638b4

Browse files
committed
Decompose Deployer RBAC & Role Binding Cleanup
This commit creates a new ClusterRole specifically for use by the 'pgo-deployer-sa' ServiceAccount. With this new role all privileges required for the deployer container to successfully perform a PostgreSQL Operator installation are now explicitly defined in the 'pgo-deployer-cr' ClusterRole (which is located in the 'postgres-operator.yaml' specification). This means the deployer container, and therefore installing via 'kubectl', no longer requires the use of "cluster-admin". Also, various ClusterRoleBindings/RoleBindings that were recently updated to use "kind: ServiceAccount" have been updated to remove the "apiGroup", ensuring the bindings can be successfully created.
1 parent eb58630 commit 54638b4

File tree

6 files changed

+97
-13
lines changed

6 files changed

+97
-13
lines changed

deploy/cluster-role-bindings.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ roleRef:
88
kind: ClusterRole
99
name: pgo-cluster-role
1010
subjects:
11-
- apiGroup: rbac.authorization.k8s.io
12-
kind: ServiceAccount
11+
- kind: ServiceAccount
1312
name: postgres-operator
1413
namespace: "$PGO_OPERATOR_NAMESPACE"

deploy/role-bindings.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ roleRef:
99
kind: Role
1010
name: pgo-role
1111
subjects:
12-
- apiGroup: rbac.authorization.k8s.io
13-
kind: ServiceAccount
12+
- kind: ServiceAccount
1413
name: postgres-operator
1514
namespace: "$PGO_OPERATOR_NAMESPACE"

installers/ansible/roles/pgo-operator/templates/cluster-rbac.yaml.j2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ roleRef:
5151
kind: ClusterRole
5252
name: pgo-cluster-role
5353
subjects:
54-
- apiGroup: rbac.authorization.k8s.io
55-
kind: ServiceAccount
54+
- kind: ServiceAccount
5655
name: postgres-operator
5756
namespace: {{ pgo_operator_namespace }}

installers/ansible/roles/pgo-operator/templates/pgo-role-rbac.yaml.j2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ roleRef:
2727
kind: Role
2828
name: pgo-role
2929
subjects:
30-
- apiGroup: rbac.authorization.k8s.io
31-
kind: ServiceAccount
30+
- kind: ServiceAccount
3231
name: postgres-operator
3332
namespace: {{ pgo_operator_namespace }}

installers/image/inventory_template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,8 @@ prometheus_supplemental_groups=$PROMETHEUS_SUPPLEMENTAL_GROUPS
304304
delete_operator_namespace='$DELETE_OPERATOR_NAMESPACE'
305305
delete_watched_namespaces='$DELETE_WATCHED_NAMESPACES'
306306
delete_metrics_namespace='$DELETE_METRICS_NAMESPACE'
307+
308+
# This is a dummy value for 'pgo_client_version' to prevent the pre-flight check for this variable
309+
# from failing. This is harmless since the client will never be installed via the deployer
310+
# container, so this value will never actually be utilized during the installation.
311+
pgo_client_version=' '

installers/kubectl/postgres-operator.yml

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,102 @@ metadata:
44
name: pgo-deployer-sa
55
namespace: pgo
66
---
7+
kind: ClusterRole
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
metadata:
10+
name: pgo-deployer-cr
11+
rules:
12+
- apiGroups:
13+
- ''
14+
resources:
15+
- namespaces
16+
verbs:
17+
- get
18+
- list
19+
- create
20+
- delete
21+
- apiGroups:
22+
- ''
23+
resources:
24+
- secrets
25+
verbs:
26+
- get
27+
- create
28+
- delete
29+
- apiGroups:
30+
- ''
31+
resources:
32+
- configmaps
33+
- services
34+
- serviceaccounts
35+
- persistentvolumeclaims
36+
verbs:
37+
- create
38+
- delete
39+
- apiGroups:
40+
- apps
41+
resources:
42+
- deployments
43+
verbs:
44+
- get
45+
- list
46+
- create
47+
- delete
48+
- apiGroups:
49+
- apiextensions.k8s.io
50+
resources:
51+
- customresourcedefinitions
52+
verbs:
53+
- get
54+
- create
55+
- delete
56+
- apiGroups:
57+
- rbac.authorization.k8s.io
58+
resources:
59+
- clusterroles
60+
- clusterrolebindings
61+
- roles
62+
- rolebindings
63+
verbs:
64+
- create
65+
- delete
66+
- bind
67+
- escalate
68+
- apiGroups:
69+
- rbac.authorization.k8s.io
70+
resources:
71+
- roles
72+
verbs:
73+
- create
74+
- delete
75+
- apiGroups:
76+
- batch
77+
resources:
78+
- jobs
79+
verbs:
80+
- delete
81+
- apiGroups:
82+
- crunchydata.com
83+
resources:
84+
- pgclusters
85+
- pgreplicas
86+
- pgpolicies
87+
- pgtasks
88+
verbs:
89+
- delete
90+
---
791
apiVersion: rbac.authorization.k8s.io/v1
892
kind: ClusterRoleBinding
993
metadata:
1094
name: pgo-deployer-crb
11-
namespace: pgo
1295
roleRef:
1396
apiGroup: rbac.authorization.k8s.io
1497
kind: ClusterRole
15-
name: cluster-admin
98+
name: pgo-deployer-cr
1699
subjects:
17-
- apiGroup: rbac.authorization.k8s.io
18-
kind: User
19-
name: system:serviceaccount:pgo:pgo-deployer-sa
100+
- kind: ServiceAccount
101+
name: pgo-deployer-sa
102+
namespace: pgo
20103
---
21104
apiVersion: batch/v1
22105
kind: Job

0 commit comments

Comments
 (0)