Skip to content

Commit e5ba007

Browse files
committed
UPSTREAM: <carry>: allow kubelet to self-authorize metrics scraping
1 parent 77a09d3 commit e5ba007

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

cmd/kubelet/app/auth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func BuildAuth(nodeName types.NodeName, client clientset.Interface, config kubel
6060
if err != nil {
6161
return nil, nil, err
6262
}
63+
authorizer = wrapAuthorizerWithMetricsScraper(authorizer)
6364

6465
return server.NewKubeletAuth(authenticator, attributes, authorizer), runAuthenticatorCAReload, nil
6566
}

cmd/kubelet/app/patch_auth.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package app
2+
3+
import (
4+
"github.com/openshift/library-go/pkg/authorization/hardcodedauthorizer"
5+
"k8s.io/apiserver/pkg/authorization/authorizer"
6+
"k8s.io/apiserver/pkg/authorization/union"
7+
)
8+
9+
// wrapAuthorizerWithMetricsScraper add an authorizer to always approver the openshift metrics scraper.
10+
// This eliminates an unnecessary SAR for scraping metrics and enables metrics gathering when network access
11+
// to the kube-apiserver is interrupted
12+
func wrapAuthorizerWithMetricsScraper(authz authorizer.Authorizer) authorizer.Authorizer {
13+
return union.New(
14+
hardcodedauthorizer.NewHardCodedMetricsAuthorizer(),
15+
authz,
16+
)
17+
}

0 commit comments

Comments
 (0)