mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	increase discovery burst for kube-controller-manager
This commit is contained in:
		@@ -466,8 +466,8 @@ func CreateControllerContext(s *config.CompletedConfig, rootClientBuilder, clien
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Use a discovery client capable of being refreshed.
 | 
						// Use a discovery client capable of being refreshed.
 | 
				
			||||||
	discoveryClient := rootClientBuilder.ClientOrDie("controller-discovery")
 | 
						discoveryClient := rootClientBuilder.DiscoveryClientOrDie("controller-discovery")
 | 
				
			||||||
	cachedClient := cacheddiscovery.NewMemCacheClient(discoveryClient.Discovery())
 | 
						cachedClient := cacheddiscovery.NewMemCacheClient(discoveryClient)
 | 
				
			||||||
	restMapper := restmapper.NewDeferredDiscoveryRESTMapper(cachedClient)
 | 
						restMapper := restmapper.NewDeferredDiscoveryRESTMapper(cachedClient)
 | 
				
			||||||
	go wait.Until(func() {
 | 
						go wait.Until(func() {
 | 
				
			||||||
		restMapper.Reset()
 | 
							restMapper.Reset()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -441,7 +441,8 @@ func startPodGCController(ctx ControllerContext) (http.Handler, bool, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func startResourceQuotaController(ctx ControllerContext) (http.Handler, bool, error) {
 | 
					func startResourceQuotaController(ctx ControllerContext) (http.Handler, bool, error) {
 | 
				
			||||||
	resourceQuotaControllerClient := ctx.ClientBuilder.ClientOrDie("resourcequota-controller")
 | 
						resourceQuotaControllerClient := ctx.ClientBuilder.ClientOrDie("resourcequota-controller")
 | 
				
			||||||
	discoveryFunc := resourceQuotaControllerClient.Discovery().ServerPreferredNamespacedResources
 | 
						resourceQuotaControllerDiscoveryClient := ctx.ClientBuilder.DiscoveryClientOrDie("resourcequota-controller")
 | 
				
			||||||
 | 
						discoveryFunc := resourceQuotaControllerDiscoveryClient.ServerPreferredNamespacedResources
 | 
				
			||||||
	listerFuncForResource := generic.ListerFuncForResourceFunc(ctx.InformerFactory.ForResource)
 | 
						listerFuncForResource := generic.ListerFuncForResourceFunc(ctx.InformerFactory.ForResource)
 | 
				
			||||||
	quotaConfiguration := quotainstall.NewQuotaConfigurationForControllers(listerFuncForResource)
 | 
						quotaConfiguration := quotainstall.NewQuotaConfigurationForControllers(listerFuncForResource)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -535,6 +536,7 @@ func startGarbageCollectorController(ctx ControllerContext) (http.Handler, bool,
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	gcClientset := ctx.ClientBuilder.ClientOrDie("generic-garbage-collector")
 | 
						gcClientset := ctx.ClientBuilder.ClientOrDie("generic-garbage-collector")
 | 
				
			||||||
 | 
						discoveryClient := ctx.ClientBuilder.DiscoveryClientOrDie("generic-garbage-collector")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	config := ctx.ClientBuilder.ConfigOrDie("generic-garbage-collector")
 | 
						config := ctx.ClientBuilder.ConfigOrDie("generic-garbage-collector")
 | 
				
			||||||
	metadataClient, err := metadata.NewForConfig(config)
 | 
						metadataClient, err := metadata.NewForConfig(config)
 | 
				
			||||||
@@ -564,7 +566,7 @@ func startGarbageCollectorController(ctx ControllerContext) (http.Handler, bool,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Periodically refresh the RESTMapper with new discovery information and sync
 | 
						// Periodically refresh the RESTMapper with new discovery information and sync
 | 
				
			||||||
	// the garbage collector.
 | 
						// the garbage collector.
 | 
				
			||||||
	go garbageCollector.Sync(gcClientset.Discovery(), 30*time.Second, ctx.Stop)
 | 
						go garbageCollector.Sync(discoveryClient, 30*time.Second, ctx.Stop)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return garbagecollector.NewDebugHandler(garbageCollector), true, nil
 | 
						return garbagecollector.NewDebugHandler(garbageCollector), true, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,6 +45,17 @@ func (m TestClientBuilder) ClientOrDie(name string) clientset.Interface {
 | 
				
			|||||||
	return m.clientset
 | 
						return m.clientset
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m TestClientBuilder) DiscoveryClient(name string) (discovery.DiscoveryInterface, error) {
 | 
				
			||||||
 | 
						return m.clientset.Discovery(), nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func (m TestClientBuilder) DiscoveryClientOrDie(name string) discovery.DiscoveryInterface {
 | 
				
			||||||
 | 
						ret, err := m.DiscoveryClient(name)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							panic(err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return ret
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// FakeDiscoveryWithError inherits DiscoveryInterface(via FakeDiscovery) with some methods accepting testing data.
 | 
					// FakeDiscoveryWithError inherits DiscoveryInterface(via FakeDiscovery) with some methods accepting testing data.
 | 
				
			||||||
type FakeDiscoveryWithError struct {
 | 
					type FakeDiscoveryWithError struct {
 | 
				
			||||||
	fakediscovery.FakeDiscovery
 | 
						fakediscovery.FakeDiscovery
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,7 @@ limitations under the License.
 | 
				
			|||||||
package clientbuilder
 | 
					package clientbuilder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"k8s.io/client-go/discovery"
 | 
				
			||||||
	clientset "k8s.io/client-go/kubernetes"
 | 
						clientset "k8s.io/client-go/kubernetes"
 | 
				
			||||||
	restclient "k8s.io/client-go/rest"
 | 
						restclient "k8s.io/client-go/rest"
 | 
				
			||||||
	"k8s.io/klog/v2"
 | 
						"k8s.io/klog/v2"
 | 
				
			||||||
@@ -30,6 +31,8 @@ type ControllerClientBuilder interface {
 | 
				
			|||||||
	ConfigOrDie(name string) *restclient.Config
 | 
						ConfigOrDie(name string) *restclient.Config
 | 
				
			||||||
	Client(name string) (clientset.Interface, error)
 | 
						Client(name string) (clientset.Interface, error)
 | 
				
			||||||
	ClientOrDie(name string) clientset.Interface
 | 
						ClientOrDie(name string) clientset.Interface
 | 
				
			||||||
 | 
						DiscoveryClient(name string) (discovery.DiscoveryInterface, error)
 | 
				
			||||||
 | 
						DiscoveryClientOrDie(name string) discovery.DiscoveryInterface
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SimpleControllerClientBuilder returns a fixed client with different user agents
 | 
					// SimpleControllerClientBuilder returns a fixed client with different user agents
 | 
				
			||||||
@@ -72,3 +75,28 @@ func (b SimpleControllerClientBuilder) ClientOrDie(name string) clientset.Interf
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	return client
 | 
						return client
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// DiscoveryClientOrDie returns a discovery.DiscoveryInterface built from the ClientBuilder
 | 
				
			||||||
 | 
					// Discovery is special because it will artificially pump the burst quite high to handle the many discovery requests.
 | 
				
			||||||
 | 
					func (b SimpleControllerClientBuilder) DiscoveryClient(name string) (discovery.DiscoveryInterface, error) {
 | 
				
			||||||
 | 
						clientConfig, err := b.Config(name)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						// Discovery makes a lot of requests infrequently.  This allows the burst to succeed and refill to happen
 | 
				
			||||||
 | 
						// in just a few seconds.
 | 
				
			||||||
 | 
						clientConfig.Burst = 200
 | 
				
			||||||
 | 
						clientConfig.QPS = 20
 | 
				
			||||||
 | 
						return clientset.NewForConfig(clientConfig)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// DiscoveryClientOrDie returns a discovery.DiscoveryInterface built from the ClientBuilder with no error.
 | 
				
			||||||
 | 
					// Discovery is special because it will artificially pump the burst quite high to handle the many discovery requests.
 | 
				
			||||||
 | 
					// If it gets an error getting the client, it will log the error and kill the process it's running in.
 | 
				
			||||||
 | 
					func (b SimpleControllerClientBuilder) DiscoveryClientOrDie(name string) discovery.DiscoveryInterface {
 | 
				
			||||||
 | 
						client, err := b.DiscoveryClient(name)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							klog.Fatal(err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return client
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,6 +31,7 @@ import (
 | 
				
			|||||||
	"k8s.io/apimachinery/pkg/util/clock"
 | 
						"k8s.io/apimachinery/pkg/util/clock"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/wait"
 | 
						"k8s.io/apimachinery/pkg/util/wait"
 | 
				
			||||||
	apiserverserviceaccount "k8s.io/apiserver/pkg/authentication/serviceaccount"
 | 
						apiserverserviceaccount "k8s.io/apiserver/pkg/authentication/serviceaccount"
 | 
				
			||||||
 | 
						"k8s.io/client-go/discovery"
 | 
				
			||||||
	clientset "k8s.io/client-go/kubernetes"
 | 
						clientset "k8s.io/client-go/kubernetes"
 | 
				
			||||||
	v1core "k8s.io/client-go/kubernetes/typed/core/v1"
 | 
						v1core "k8s.io/client-go/kubernetes/typed/core/v1"
 | 
				
			||||||
	restclient "k8s.io/client-go/rest"
 | 
						restclient "k8s.io/client-go/rest"
 | 
				
			||||||
@@ -155,6 +156,26 @@ func (t *DynamicControllerClientBuilder) ClientOrDie(name string) clientset.Inte
 | 
				
			|||||||
	return client
 | 
						return client
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (t *DynamicControllerClientBuilder) DiscoveryClient(name string) (discovery.DiscoveryInterface, error) {
 | 
				
			||||||
 | 
						clientConfig, err := t.Config(name)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						// Discovery makes a lot of requests infrequently.  This allows the burst to succeed and refill to happen
 | 
				
			||||||
 | 
						// in just a few seconds.
 | 
				
			||||||
 | 
						clientConfig.Burst = 200
 | 
				
			||||||
 | 
						clientConfig.QPS = 20
 | 
				
			||||||
 | 
						return clientset.NewForConfig(clientConfig)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (t *DynamicControllerClientBuilder) DiscoveryClientOrDie(name string) discovery.DiscoveryInterface {
 | 
				
			||||||
 | 
						client, err := t.DiscoveryClient(name)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							klog.Fatal(err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return client
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type tokenSourceImpl struct {
 | 
					type tokenSourceImpl struct {
 | 
				
			||||||
	namespace          string
 | 
						namespace          string
 | 
				
			||||||
	serviceAccountName string
 | 
						serviceAccountName string
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user