Skip to content

Commit b8c781a

Browse files
committed
OCPBUGS-31353: Minimize wildcard privileges
- Added operand namespaces in the operator payload to be able to create local roles. - Added local roles and rolebinding in the operand namespaces to manage ingresscontrollers and canary. - Added a local role for the certificate management in openshift-config-managed namespace. - Limited cluster permissions on namespace resource to operand namespaces. - Moved role and rolebinding permissions from cluster level to openshift-config local role. TODO: clusterroles/clusterrolebinding.
1 parent edf5e71 commit b8c781a

File tree

4 files changed

+183
-14
lines changed

4 files changed

+183
-14
lines changed

manifests/00-cluster-role.yaml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ rules:
1414
- apiGroups:
1515
- ""
1616
resources:
17-
- configmaps
18-
- namespaces
19-
- serviceaccounts
2017
- endpoints
2118
- services
22-
- secrets
2319
- pods
2420
- events
2521
verbs:
@@ -28,24 +24,26 @@ rules:
2824
- apiGroups:
2925
- ""
3026
resources:
31-
- pods/eviction
27+
- namespaces
28+
resourceNames:
29+
- openshift-ingress
30+
- openshift-ingress-canary
3231
verbs:
33-
- "create"
32+
- "*"
3433

3534
- apiGroups:
3635
- ""
3736
resources:
38-
- nodes
37+
- pods/eviction
3938
verbs:
40-
- list
39+
- "create"
4140

4241
- apiGroups:
43-
- apps
42+
- ""
4443
resources:
45-
- deployments
46-
- daemonsets
44+
- nodes
4745
verbs:
48-
- "*"
46+
- list
4947

5048
- apiGroups:
5149
- policy
@@ -68,8 +66,6 @@ rules:
6866
resources:
6967
- clusterroles
7068
- clusterrolebindings
71-
- roles
72-
- rolebindings
7369
verbs:
7470
- create
7571
- get

manifests/00-operand-namespace.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Define operand namespaces to be able to restrict the operator's RBAC permissions.
2+
# This enables limiting the access to sensitive resources (e.g., Secrets, ServiceAccounts, ConfigMaps)
3+
# from cluster-wide scope to specific namespaces.
4+
---
5+
kind: Namespace
6+
apiVersion: v1
7+
metadata:
8+
annotations:
9+
capability.openshift.io/name: Ingress
10+
include.release.openshift.io/ibm-cloud-managed: "true"
11+
include.release.openshift.io/self-managed-high-availability: "true"
12+
include.release.openshift.io/single-node-developer: "true"
13+
openshift.io/node-selector: ""
14+
workload.openshift.io/allowed: "management"
15+
labels:
16+
# allow openshift-monitoring to look for ServiceMonitor objects in this namespace
17+
openshift.io/cluster-monitoring: "true"
18+
name: openshift-ingress
19+
# old and new forms of the label for matching with NetworkPolicy
20+
network.openshift.io/policy-group: ingress
21+
policy-group.network.openshift.io/ingress: ""
22+
# Router deployment needs to allow privilege escalation, as well as host
23+
# network and host ports for the "HostNetwork" endpoint publishing strategy,
24+
# which is the default for on-premise platforms.
25+
pod-security.kubernetes.io/enforce: privileged
26+
pod-security.kubernetes.io/audit: privileged
27+
pod-security.kubernetes.io/warn: privileged
28+
name: openshift-ingress
29+
---
30+
kind: Namespace
31+
apiVersion: v1
32+
metadata:
33+
annotations:
34+
capability.openshift.io/name: Ingress
35+
include.release.openshift.io/ibm-cloud-managed: "true"
36+
include.release.openshift.io/self-managed-high-availability: "true"
37+
include.release.openshift.io/single-node-developer: "true"
38+
openshift.io/node-selector: ""
39+
workload.openshift.io/allowed: "management"
40+
name: openshift-ingress-canary

manifests/01-role-binding.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,45 @@ roleRef:
3838
kind: Role
3939
apiGroup: rbac.authorization.k8s.io
4040
name: ingress-operator
41+
---
42+
# RoleBinding for the operator to manage ingresscontrollers
43+
# in the openshift-ingress namespace.
44+
kind: RoleBinding
45+
apiVersion: rbac.authorization.k8s.io/v1
46+
metadata:
47+
name: ingress-operator
48+
namespace: openshift-ingress
49+
annotations:
50+
capability.openshift.io/name: Ingress
51+
include.release.openshift.io/ibm-cloud-managed: "true"
52+
include.release.openshift.io/self-managed-high-availability: "true"
53+
include.release.openshift.io/single-node-developer: "true"
54+
subjects:
55+
- kind: ServiceAccount
56+
name: ingress-operator
57+
namespace: openshift-ingress-operator
58+
roleRef:
59+
kind: Role
60+
apiGroup: rbac.authorization.k8s.io
61+
name: ingress-operator
62+
---
63+
# RoleBinding for the operator to manage canary deployment
64+
# in the openshift-ingress-canary namespace.
65+
kind: RoleBinding
66+
apiVersion: rbac.authorization.k8s.io/v1
67+
metadata:
68+
name: ingress-operator
69+
namespace: openshift-ingress-canary
70+
annotations:
71+
capability.openshift.io/name: Ingress
72+
include.release.openshift.io/ibm-cloud-managed: "true"
73+
include.release.openshift.io/self-managed-high-availability: "true"
74+
include.release.openshift.io/single-node-developer: "true"
75+
subjects:
76+
- kind: ServiceAccount
77+
name: ingress-operator
78+
namespace: openshift-ingress-operator
79+
roleRef:
80+
kind: Role
81+
apiGroup: rbac.authorization.k8s.io
82+
name: ingress-operator

manifests/01-role.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,94 @@ rules:
5858
- rolebindings
5959
verbs:
6060
- delete
61+
- create
62+
- update
63+
- get
64+
- list
65+
- watch
66+
---
67+
# Role for the operator to manage the router certificates
68+
# in openshift-config-managed namespace.
69+
kind: Role
70+
apiVersion: rbac.authorization.k8s.io/v1
71+
metadata:
72+
name: ingress-operator
73+
namespace: openshift-config-managed
74+
annotations:
75+
capability.openshift.io/name: Ingress
76+
include.release.openshift.io/ibm-cloud-managed: "true"
77+
include.release.openshift.io/self-managed-high-availability: "true"
78+
include.release.openshift.io/single-node-developer: "true"
79+
rules:
80+
- apiGroups:
81+
- ""
82+
resources:
83+
- secrets
84+
resourceNames:
85+
- router-certs
86+
verbs:
87+
- "*"
88+
- apiGroups:
89+
- ""
90+
resources:
91+
- configmaps
92+
resourceNames:
93+
- default-ingress-cert
94+
verbs:
95+
- "*"
96+
---
97+
# Role for the operator to manage ingress controllers
98+
# in openshift-ingress namespace.
99+
kind: Role
100+
apiVersion: rbac.authorization.k8s.io/v1
101+
metadata:
102+
name: ingress-operator
103+
namespace: openshift-ingress
104+
annotations:
105+
capability.openshift.io/name: Ingress
106+
include.release.openshift.io/ibm-cloud-managed: "true"
107+
include.release.openshift.io/self-managed-high-availability: "true"
108+
include.release.openshift.io/single-node-developer: "true"
109+
rules:
110+
- apiGroups:
111+
- ""
112+
resources:
113+
- secrets
114+
- configmaps
115+
- serviceaccounts
116+
verbs:
117+
- "*"
118+
- apiGroups:
119+
- apps
120+
resources:
121+
- deployments
122+
verbs:
123+
- "*"
124+
---
125+
# Role for the operator to manage canary deployment
126+
# in openshift-ingress-canary namespace.
127+
kind: Role
128+
apiVersion: rbac.authorization.k8s.io/v1
129+
metadata:
130+
name: ingress-operator
131+
namespace: openshift-ingress-canary
132+
annotations:
133+
capability.openshift.io/name: Ingress
134+
include.release.openshift.io/ibm-cloud-managed: "true"
135+
include.release.openshift.io/self-managed-high-availability: "true"
136+
include.release.openshift.io/single-node-developer: "true"
137+
rules:
138+
- apiGroups:
139+
- ""
140+
resources:
141+
- secrets
142+
- configmaps
143+
- serviceaccounts
144+
verbs:
145+
- "*"
146+
- apiGroups:
147+
- apps
148+
resources:
149+
- daemonsets
150+
verbs:
151+
- "*"

0 commit comments

Comments
 (0)