Skip to content

Commit 8c8dab2

Browse files
deads2kbertinatto
authored andcommitted
UPSTREAM: <carry>: allow kubelet to self-authorize metrics scraping
OpenShift-Rebase-Source: 5ab0f5e
1 parent 508c35c commit 8c8dab2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

cmd/kubelet/app/auth.go

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func BuildAuth(nodeName types.NodeName, client clientset.Interface, config kubel
6262
if err != nil {
6363
return nil, nil, err
6464
}
65+
authorizer = wrapAuthorizerWithMetricsScraper(authorizer)
6566

6667
return server.NewKubeletAuth(authenticator, attributes, authorizer), runAuthenticatorCAReload, nil
6768
}

cmd/kubelet/app/patch_auth.go

+17
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)