add authz webhook matchcondition metrics
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com> Signed-off-by: Jordan Liggitt <liggitt@google.com> Co-authored-by: Jordan Liggitt <liggitt@google.com>
This commit is contained in:
@@ -32,11 +32,13 @@ import (
|
||||
"k8s.io/apiserver/pkg/authentication/user"
|
||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||
"k8s.io/apiserver/pkg/authorization/authorizerfactory"
|
||||
"k8s.io/apiserver/pkg/authorization/cel"
|
||||
authorizationmetrics "k8s.io/apiserver/pkg/authorization/metrics"
|
||||
"k8s.io/apiserver/pkg/authorization/union"
|
||||
"k8s.io/apiserver/pkg/server/options/authorizationconfig/metrics"
|
||||
webhookutil "k8s.io/apiserver/pkg/util/webhook"
|
||||
"k8s.io/apiserver/plugin/pkg/authorizer/webhook"
|
||||
webhookmetrics "k8s.io/apiserver/plugin/pkg/authorizer/webhook/metrics"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubernetes/pkg/auth/authorizer/abac"
|
||||
"k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes"
|
||||
@@ -142,6 +144,8 @@ func (r *reloadableAuthorizerResolver) newForConfig(authzConfig *authzconfig.Aut
|
||||
*r.initialConfig.WebhookRetryBackoff,
|
||||
decisionOnError,
|
||||
configuredAuthorizer.Webhook.MatchConditions,
|
||||
configuredAuthorizer.Name,
|
||||
kubeapiserverWebhookMetrics{MatcherMetrics: cel.NewMatcherMetrics()},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -162,6 +166,13 @@ func (r *reloadableAuthorizerResolver) newForConfig(authzConfig *authzconfig.Aut
|
||||
return union.New(authorizers...), union.NewRuleResolvers(ruleResolvers...), nil
|
||||
}
|
||||
|
||||
type kubeapiserverWebhookMetrics struct {
|
||||
// kube-apiserver doesn't report request metrics
|
||||
webhookmetrics.NoopRequestMetrics
|
||||
// kube-apiserver does report matchCondition metrics
|
||||
cel.MatcherMetrics
|
||||
}
|
||||
|
||||
// runReload starts checking the config file for changes and reloads the authorizer when it changes.
|
||||
// Blocks until ctx is complete.
|
||||
func (r *reloadableAuthorizerResolver) runReload(ctx context.Context) {
|
||||
|
||||
Reference in New Issue
Block a user