Skip to content

Commit 1eb607e

Browse files
committed
Fix the CRD read permissions on hosted config-policy-controllers
This accidentally used a Role instead of a ClusterRole. The ClusterRole will be the same for all hosted clusters but the ClusterRoleBinding is unique per hosted cluster since there's no way for ManifestWork to merge the subjects array. Relates: https://issues.redhat.com/browse/ACM-2923 Signed-off-by: mprahl <[email protected]>
1 parent bda8f42 commit 1eb607e

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

pkg/addon/configpolicy/manifests/managedclusterchart/templates/cluster_role.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ kind: Role
77
kind: ClusterRole
88
{{- end }}
99
metadata:
10-
creationTimestamp: null
1110
name: {{ include "controller.rolename" . }}
1211
{{- if eq .Values.installMode "Hosted" }}
1312
namespace: {{ .Release.Namespace }}
@@ -78,16 +77,6 @@ rules:
7877
- get
7978
- list
8079
- watch
81-
- apiGroups:
82-
- apiextensions.k8s.io
83-
resources:
84-
- customresourcedefinitions
85-
resourceNames:
86-
- configurationpolicies.policy.open-cluster-management.io
87-
verbs:
88-
- get
89-
- list
90-
- watch
9180
{{- else }}
9281
- apiGroups:
9382
- '*'

pkg/addon/configpolicy/manifests/managedclusterchart/templates/cluster_role_binding.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ kind: RoleBinding
77
kind: ClusterRoleBinding
88
{{- end }}
99
metadata:
10-
creationTimestamp: null
1110
name: {{ include "controller.rolename" . }}
1211
{{- if eq .Values.installMode "Hosted" }}
1312
namespace: {{ .Release.Namespace }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright Contributors to the Open Cluster Management project
2+
3+
{{- if eq .Values.installMode "Hosted" }}
4+
---
5+
apiVersion: rbac.authorization.k8s.io/v1
6+
kind: ClusterRoleBinding
7+
metadata:
8+
name: ocm:{{ .Release.Namespace }}:{{ include "controller.fullname" . }}
9+
labels:
10+
app: {{ include "controller.fullname" . }}
11+
chart: {{ include "controller.chart" . }}
12+
release: {{ .Release.Name }}
13+
heritage: {{ .Release.Service }}
14+
addon.open-cluster-management.io/hosted-manifest-location: hosting
15+
roleRef:
16+
apiGroup: rbac.authorization.k8s.io
17+
kind: ClusterRole
18+
name: ocm:{{ include "controller.fullname" . }}
19+
subjects:
20+
- kind: ServiceAccount
21+
name: {{ include "controller.serviceAccountName" . }}
22+
namespace: {{ .Release.Namespace }}
23+
{{- end }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright Contributors to the Open Cluster Management project
2+
3+
{{- if eq .Values.installMode "Hosted" }}
4+
---
5+
apiVersion: rbac.authorization.k8s.io/v1
6+
kind: ClusterRole
7+
metadata:
8+
name: ocm:{{ include "controller.fullname" . }}
9+
labels:
10+
app: {{ include "controller.fullname" . }}
11+
chart: {{ include "controller.chart" . }}
12+
release: {{ .Release.Name }}
13+
heritage: {{ .Release.Service }}
14+
addon.open-cluster-management.io/hosted-manifest-location: hosting
15+
rules:
16+
- apiGroups:
17+
- apiextensions.k8s.io
18+
resources:
19+
- customresourcedefinitions
20+
resourceNames:
21+
- configurationpolicies.policy.open-cluster-management.io
22+
verbs:
23+
- get
24+
- list
25+
- watch
26+
{{- end }}

0 commit comments

Comments
 (0)