Merge pull request #97957 from yue9944882/aa-server-apf-optionality

Disables APF if the aggregated apiserver cannot locate the core kube-apiserver
This commit is contained in:
Kubernetes Prow Robot 2021-01-13 07:50:36 -08:00 committed by GitHub
commit 5c58b22251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,7 @@ import (
utilflowcontrol "k8s.io/apiserver/pkg/util/flowcontrol" utilflowcontrol "k8s.io/apiserver/pkg/util/flowcontrol"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/component-base/featuregate" "k8s.io/component-base/featuregate"
"k8s.io/klog/v2"
) )
// RecommendedOptions contains the recommended options for running an API server. // RecommendedOptions contains the recommended options for running an API server.
@ -124,12 +125,16 @@ func (o *RecommendedOptions) ApplyTo(config *server.RecommendedConfig) error {
return err return err
} }
if feature.DefaultFeatureGate.Enabled(features.APIPriorityAndFairness) { if feature.DefaultFeatureGate.Enabled(features.APIPriorityAndFairness) {
config.FlowControl = utilflowcontrol.New( if config.ClientConfig != nil {
config.SharedInformerFactory, config.FlowControl = utilflowcontrol.New(
kubernetes.NewForConfigOrDie(config.ClientConfig).FlowcontrolV1beta1(), config.SharedInformerFactory,
config.MaxRequestsInFlight+config.MaxMutatingRequestsInFlight, kubernetes.NewForConfigOrDie(config.ClientConfig).FlowcontrolV1beta1(),
config.RequestTimeout/4, config.MaxRequestsInFlight+config.MaxMutatingRequestsInFlight,
) config.RequestTimeout/4,
)
} else {
klog.Warningf("Neither kubeconfig is provided nor service-account is mounted, so APIPriorityAndFairness will be disabled")
}
} }
return nil return nil
} }