Skip to content

Commit

Permalink
UPSTREAM: <carry>: allow kubelet to self-authorize metrics scraping
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k authored and damemi committed Aug 27, 2021
1 parent 4868ad2 commit 0e49040
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/kubelet/app/auth.go
Expand Up @@ -60,6 +60,7 @@ func BuildAuth(nodeName types.NodeName, client clientset.Interface, config kubel
if err != nil {
return nil, nil, err
}
authorizer = wrapAuthorizerWithMetricsScraper(authorizer)

return server.NewKubeletAuth(authenticator, attributes, authorizer), runAuthenticatorCAReload, nil
}
Expand Down
17 changes: 17 additions & 0 deletions cmd/kubelet/app/patch_auth.go
@@ -0,0 +1,17 @@
package app

import (
"github.com/openshift/library-go/pkg/authorization/hardcodedauthorizer"
"k8s.io/apiserver/pkg/authorization/authorizer"
"k8s.io/apiserver/pkg/authorization/union"
)

// wrapAuthorizerWithMetricsScraper add an authorizer to always approver the openshift metrics scraper.
// This eliminates an unnecessary SAR for scraping metrics and enables metrics gathering when network access
// to the kube-apiserver is interrupted
func wrapAuthorizerWithMetricsScraper(authz authorizer.Authorizer) authorizer.Authorizer {
return union.New(
hardcodedauthorizer.NewHardCodedMetricsAuthorizer(),
authz,
)
}

0 comments on commit 0e49040

Please sign in to comment.