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
OpenShift-Rebase-Source: 5ab0f5e
  • Loading branch information
deads2k authored and bertinatto committed Mar 6, 2024
1 parent 5123525 commit b6cc9bf
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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
Original file line number Diff line number Diff line change
@@ -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 b6cc9bf

Please sign in to comment.