@@ -25,6 +25,7 @@ import (
25
25
"k8s.io/apiserver/pkg/authentication/serviceaccount"
26
26
"k8s.io/apiserver/pkg/authentication/user"
27
27
utilfeature "k8s.io/apiserver/pkg/util/feature"
28
+ zpagesfeatures "k8s.io/component-base/zpages/features"
28
29
29
30
rbacv1helpers "k8s.io/kubernetes/pkg/apis/rbac/v1"
30
31
"k8s.io/kubernetes/pkg/features"
@@ -194,6 +195,18 @@ func NodeRules() []rbacv1.PolicyRule {
194
195
195
196
// ClusterRoles returns the cluster roles to bootstrap an API server with
196
197
func ClusterRoles () []rbacv1.ClusterRole {
198
+ monitoringRules := []rbacv1.PolicyRule {
199
+ rbacv1helpers .NewRule ("get" ).URLs (
200
+ "/metrics" , "/metrics/slis" ,
201
+ "/livez" , "/readyz" , "/healthz" ,
202
+ "/livez/*" , "/readyz/*" , "/healthz/*" ,
203
+ ).RuleOrDie (),
204
+ }
205
+
206
+ if utilfeature .DefaultFeatureGate .Enabled (zpagesfeatures .ComponentStatusz ) {
207
+ monitoringRules = append (monitoringRules , rbacv1helpers .NewRule ("get" ).URLs ("/statusz" ).RuleOrDie ())
208
+ }
209
+
197
210
roles := []rbacv1.ClusterRole {
198
211
{
199
212
// a "root" role which can do absolutely anything
@@ -223,13 +236,7 @@ func ClusterRoles() []rbacv1.ClusterRole {
223
236
// The splatted health check endpoints allow read access to individual health check
224
237
// endpoints which may contain more sensitive cluster information information
225
238
ObjectMeta : metav1.ObjectMeta {Name : "system:monitoring" },
226
- Rules : []rbacv1.PolicyRule {
227
- rbacv1helpers .NewRule ("get" ).URLs (
228
- "/metrics" , "/metrics/slis" ,
229
- "/livez" , "/readyz" , "/healthz" ,
230
- "/livez/*" , "/readyz/*" , "/healthz/*" ,
231
- ).RuleOrDie (),
232
- },
239
+ Rules : monitoringRules ,
233
240
},
234
241
}
235
242
0 commit comments