Skip to content

Commit f4e9de7

Browse files
jkatzpmereddy
andauthored
Modify roles for pgo-target-role
This moves the "replicasets" resource to be under the "apps" group, where it really should have been all along (at least since 1.9). This also adds an explicit permission for viewing pods/logs. Co-authored-by: Pramodh Mereddy <[email protected]> Issue: [ch10081]
1 parent abab938 commit f4e9de7

File tree

6 files changed

+57
-22
lines changed

6 files changed

+57
-22
lines changed

deploy/cluster-roles.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ rules:
4141
- endpoints
4242
- pods
4343
- pods/exec
44-
- pods/log
45-
- replicasets
4644
- secrets
4745
- services
4846
- persistentvolumeclaims
@@ -55,10 +53,19 @@ rules:
5553
- update
5654
- delete
5755
- deletecollection
56+
- apiGroups:
57+
- ''
58+
resources:
59+
- pods/log
60+
verbs:
61+
- get
62+
- list
63+
- watch
5864
- apiGroups:
5965
- apps
6066
resources:
6167
- deployments
68+
- replicasets
6269
verbs:
6370
- get
6471
- list

docs/content/architecture/namespace.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ settings.
3434

3535
Enables full dynamic namespace capabilities, in which the Operator can create, delete and update
3636
any namespaces within a Kubernetes cluster. With `dynamic` mode enabled, the PostgreSQL Operator
37-
can respond to namespace events in a Kubernetes cluster, such as when a namespace is created, and
38-
take an appropriate action, such as adding the PostgreSQL Operator controllers for the newly
37+
can respond to namespace events in a Kubernetes cluster, such as when a namespace is created, and
38+
take an appropriate action, such as adding the PostgreSQL Operator controllers for the newly
3939
created namespace.
4040

4141
The following defines the namespace permissions required for the `dynamic` mode to be enabled:
@@ -62,8 +62,8 @@ rules:
6262
6363
### `readonly`
6464

65-
In `readonly` mode, the PostgreSQL Operator is still able to listen to namespace events within a
66-
Kubernetes cluster, but it can no longer modify (create, update, delete) namespaces. For example,
65+
In `readonly` mode, the PostgreSQL Operator is still able to listen to namespace events within a
66+
Kubernetes cluster, but it can no longer modify (create, update, delete) namespaces. For example,
6767
if a Kubernetes administrator creates a namespace, the PostgreSQL Operator can respond and create
6868
controllers for that namespace.
6969

@@ -95,30 +95,30 @@ Operator is unable to dynamically respond to namespace events in the cluster, i
9595
target namespaces are deleted or new target namespaces need to be added, the PostgreSQL Operator
9696
will need to be re-deployed.
9797

98-
Please note that it is important to redeploy the PostgreSQL Operator following the deletion of a
98+
Please note that it is important to redeploy the PostgreSQL Operator following the deletion of a
9999
target namespace to ensure it no longer attempts to listen for events in that namespace.
100100

101101
The `disabled` mode is enabled the when the PostgreSQL Operator has not been assigned namespace
102102
permissions.
103103

104104
## RBAC Reconciliation
105105

106-
By default, the PostgreSQL Operator will attempt to reconcile RBAC resources (ServiceAccounts,
106+
By default, the PostgreSQL Operator will attempt to reconcile RBAC resources (ServiceAccounts,
107107
Roles and RoleBindings) within each namespace configured for the PostgreSQL Operator installation.
108108
This allows the PostgreSQL Operator to create, update and delete the various RBAC resources it
109109
requires in order to properly create and manage PostgreSQL clusters within each targeted namespace
110110
(this includes self-healing RBAC resources as needed if removed and/or misconfigured).
111111

112112
In order for RBAC reconciliation to function properly, the PostgreSQL Operator ServiceAccount must
113-
be assigned a certain set of permissions. While the PostgreSQL Operator is not concerned with
113+
be assigned a certain set of permissions. While the PostgreSQL Operator is not concerned with
114114
exactly how it has been assigned the permissions required to reconcile RBAC in each target
115-
namespace, the various [installation methods]({{< relref "installation" >}}) supported by the
115+
namespace, the various [installation methods]({{< relref "installation" >}}) supported by the
116116
PostgreSQL Operator install a recommended set permissions based on the specific Namespace Operating
117117
Mode enabled (see section [Namespace Operating Modes]({{< relref "#namespace-operating-modes" >}})
118118
above for more information regarding the various Namespace Operating Modes available).
119119

120-
The following section defines the recommended set of permissions that should be assigned to the
121-
PostgreSQL Operator ServiceAccount in order to ensure proper RBAC reconciliation based on the
120+
The following section defines the recommended set of permissions that should be assigned to the
121+
PostgreSQL Operator ServiceAccount in order to ensure proper RBAC reconciliation based on the
122122
specific Namespace Operating Mode enabled. Please note that each PostgreSQL Operator installation
123123
method handles the initial configuration and setup of the permissions shown below based on the
124124
Namespace Operating Mode configured during installation.
@@ -127,7 +127,7 @@ Namespace Operating Mode configured during installation.
127127

128128
When using the `dynamic` Namespace Operating Mode, it is recommended that the PostgreSQL Operator
129129
ServiceAccount be granted permissions to manage RBAC inside any namespace in the Kubernetes cluster
130-
via a ClusterRole. This allows for a fully-hands off approach to managing RBAC within each
130+
via a ClusterRole. This allows for a fully-hands off approach to managing RBAC within each
131131
targeted namespace space. In other words, as namespaces are added and removed post-installation of
132132
the PostgreSQL Operator (e.g. using `pgo create namespace` or `pgo delete namespace`), the Operator
133133
is able to automatically reconcile RBAC in those namespaces without the need for any external
@@ -170,8 +170,6 @@ rules:
170170
- endpoints
171171
- pods
172172
- pods/exec
173-
- pods/log
174-
- replicasets
175173
- secrets
176174
- services
177175
- persistentvolumeclaims
@@ -184,10 +182,19 @@ rules:
184182
- update
185183
- delete
186184
- deletecollection
185+
- apiGroups:
186+
- ''
187+
resources:
188+
- pods/log
189+
verbs:
190+
- get
191+
- list
192+
- watch
187193
- apiGroups:
188194
- apps
189195
resources:
190196
- deployments
197+
- replicasets
191198
verbs:
192199
- get
193200
- list
@@ -230,7 +237,7 @@ rules:
230237

231238
### `readonly` & `disabled` Namespace Operating Modes
232239

233-
When using the `readonly` or `disabled` Namespace Operating Modes, it is recommended that the
240+
When using the `readonly` or `disabled` Namespace Operating Modes, it is recommended that the
234241
PostgreSQL Operator ServiceAccount be granted permissions to manage RBAC inside of any configured
235242
namespaces using local Roles within each targeted namespace. This means that as new namespaces
236243
are added and removed post-installation of the PostgreSQL Operator, an administrator must manually

installers/ansible/roles/pgo-operator/files/pgo-configs/pgo-target-role.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
"endpoints",
1616
"pods",
1717
"pods/exec",
18-
"pods/log",
19-
"replicasets",
2018
"secrets",
2119
"services",
2220
"persistentvolumeclaims"
@@ -32,12 +30,26 @@
3230
"deletecollection"
3331
]
3432
},
33+
{
34+
"apiGroups": [
35+
""
36+
],
37+
"resources": [
38+
"pods/log"
39+
],
40+
"verbs":[
41+
"get",
42+
"list",
43+
"watch"
44+
]
45+
},
3546
{
3647
"apiGroups": [
3748
"apps"
3849
],
3950
"resources": [
40-
"deployments"
51+
"deployments",
52+
"replicasets"
4153
],
4254
"verbs":[
4355
"get",

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ rules:
4242
- endpoints
4343
- pods
4444
- pods/exec
45-
- pods/log
46-
- replicasets
4745
- secrets
4846
- services
4947
- persistentvolumeclaims
@@ -56,10 +54,19 @@ rules:
5654
- update
5755
- delete
5856
- deletecollection
57+
- apiGroups:
58+
- ''
59+
resources:
60+
- pods/log
61+
verbs:
62+
- get
63+
- list
64+
- watch
5965
- apiGroups:
6066
- apps
6167
resources:
6268
- deployments
69+
- replicasets
6370
verbs:
6471
- get
6572
- list

installers/helm/templates/rbac.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ rules:
7373
- extensions
7474
resources:
7575
- deployments
76+
- replicasets
7677
verbs:
7778
- get
7879
- list
@@ -145,4 +146,4 @@ subjects:
145146
- kind: ServiceAccount
146147
name: {{ include "postgres-operator.serviceAccountName" . }}
147148
namespace: {{ .Release.Namespace }}
148-
{{ end }}
149+
{{ end }}

installers/kubectl/postgres-operator.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ rules:
6060
- extensions
6161
resources:
6262
- deployments
63+
- replicasets
6364
verbs:
6465
- get
6566
- list

0 commit comments

Comments
 (0)