From f189d35f0eb8ecec7fe75a357a0e5f5e9a2fb1b8 Mon Sep 17 00:00:00 2001 From: p0lyn0mial Date: Tue, 3 Oct 2017 18:08:30 +0200 Subject: [PATCH] removes Authorizer and ExternalClientSet from kubeapiserver's admission initializer. Kubernetes-commit: 6b1f1d14148fe3962594d8f4c9ca15d1c6171819 --- pkg/server/config.go | 5 +++++ pkg/server/options/admission.go | 5 +++-- pkg/server/options/coreapi.go | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/server/config.go b/pkg/server/config.go index 69c0e4497..9ededc431 100644 --- a/pkg/server/config.go +++ b/pkg/server/config.go @@ -192,6 +192,11 @@ type RecommendedConfig struct { // RecommendedOptions.CoreAPI.ApplyTo called by RecommendedOptions.ApplyTo. It uses an in-cluster client config // by default, or the kubeconfig given with kubeconfig command line flag. SharedInformerFactory informers.SharedInformerFactory + + // ClientConfig holds the kubernetes client configuration. + // This value is set by RecommendedOptions.CoreAPI.ApplyTo called by RecommendedOptions.ApplyTo. + // By default in-cluster client config is used. + ClientConfig *restclient.Config } type SecureServingInfo struct { diff --git a/pkg/server/options/admission.go b/pkg/server/options/admission.go index bbfd2f733..5b3e3ab3f 100644 --- a/pkg/server/options/admission.go +++ b/pkg/server/options/admission.go @@ -27,6 +27,7 @@ import ( "k8s.io/apiserver/pkg/server" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" ) // AdmissionOptions holds the admission options @@ -72,13 +73,13 @@ func (a *AdmissionOptions) AddFlags(fs *pflag.FlagSet) { // In case admission plugin names were not provided by a custer-admin they will be prepared from the recommended/default values. // In addition the method lazily initializes a generic plugin that is appended to the list of pluginInitializers // note this method uses: -// genericconfig.LoopbackClientConfig // genericconfig.Authorizer func (a *AdmissionOptions) ApplyTo( c *server.Config, informers informers.SharedInformerFactory, serverIdentifyingClientCert []byte, serverIdentifyingClientKey []byte, + clientConfig *rest.Config, pluginInitializers ...admission.PluginInitializer, ) error { pluginNames := a.PluginNames @@ -91,7 +92,7 @@ func (a *AdmissionOptions) ApplyTo( return fmt.Errorf("failed to read plugin config: %v", err) } - clientset, err := kubernetes.NewForConfig(c.LoopbackClientConfig) + clientset, err := kubernetes.NewForConfig(clientConfig) if err != nil { return err } diff --git a/pkg/server/options/coreapi.go b/pkg/server/options/coreapi.go index edcf3a7b0..d46dece4a 100644 --- a/pkg/server/options/coreapi.go +++ b/pkg/server/options/coreapi.go @@ -73,6 +73,7 @@ func (o *CoreAPIOptions) ApplyTo(config *server.RecommendedConfig) error { if err != nil { return fmt.Errorf("failed to create Kubernetes clientset: %v", err) } + config.ClientConfig = kubeconfig config.SharedInformerFactory = clientgoinformers.NewSharedInformerFactory(clientgoExternalClient, 10*time.Minute) return nil