Skip to content

Commit 46ae747

Browse files
authored
Merge pull request #47 from coroot/cnpg_perconapg_permissions
rbac: grant cluster-agent access to CNPG/Percona Operator resources
2 parents d61f97d + 107e18a commit 46ae747

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

config/rbac/role.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,25 @@ rules:
124124
- patch
125125
- update
126126
- watch
127+
- apiGroups:
128+
- pgv2.percona.com
129+
resources:
130+
- perconapgbackups
131+
- perconapgclusters
132+
verbs:
133+
- get
134+
- list
135+
- watch
136+
- apiGroups:
137+
- postgresql.cnpg.io
138+
resources:
139+
- backups
140+
- clusters
141+
- scheduledbackups
142+
verbs:
143+
- get
144+
- list
145+
- watch
127146
- apiGroups:
128147
- rbac.authorization.k8s.io
129148
resources:

controller/cluster_agent.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ func (r *CorootReconciler) clusterAgentClusterRole(cr *corootv1.Coroot) *rbacv1.
8282
Resources: []string{"applications", "applicationsets", "appprojects"},
8383
Verbs: verbs,
8484
},
85+
{
86+
APIGroups: []string{"postgresql.cnpg.io"},
87+
Resources: []string{"clusters", "backups", "scheduledbackups"},
88+
Verbs: verbs,
89+
},
90+
{
91+
APIGroups: []string{"pgv2.percona.com"},
92+
Resources: []string{"perconapgclusters", "perconapgbackups"},
93+
Verbs: verbs,
94+
},
8595
},
8696
}
8797
return role

controller/controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ func detectIngressAPIVersion(mgr ctrl.Manager) string {
134134
// +kubebuilder:rbac:groups=apiextensions.k8s.io,resources=customresourcedefinitions,verbs=get;list;watch
135135
// +kubebuilder:rbac:groups=source.toolkit.fluxcd.io;kustomize.toolkit.fluxcd.io;helm.toolkit.fluxcd.io;notification.toolkit.fluxcd.io;image.toolkit.fluxcd.io;fluxcd.controlplane.io,resources=*,verbs=get;list;watch
136136
// +kubebuilder:rbac:groups=argoproj.io,resources=applications;applicationsets;appprojects,verbs=get;list;watch
137+
// +kubebuilder:rbac:groups=postgresql.cnpg.io,resources=clusters;backups;scheduledbackups,verbs=get;list;watch
138+
// +kubebuilder:rbac:groups=pgv2.percona.com,resources=perconapgclusters;perconapgbackups,verbs=get;list;watch
137139

138140
func (r *CorootReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
139141
logger := ctrl.Log.WithValues("namespace", req.Namespace, "name", req.Name)

0 commit comments

Comments
 (0)