Documentation ¶
Index ¶
- func GetQuotableResourcesByFunc(discoveryFunc NamespacedResourcesFunc) (map[schema.GroupVersionResource]struct{}, error)
- func RecommendedDefaultResourceQuotaControllerConfiguration(obj *kubectrlmgrconfigv1alpha1.ResourceQuotaControllerConfiguration)
- func Register(ctrlCtx *controllers.Context) error
- type AccountQuotaController
- type AccountQuotaControllerOptions
- type NamespacedResourcesFunc
- type QuotaMonitor
- type ReplenishmentFunc
- type ResyncPeriodFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetQuotableResourcesByFunc ¶
func GetQuotableResourcesByFunc(discoveryFunc NamespacedResourcesFunc) (map[schema.GroupVersionResource]struct{}, error)
GetQuotableResourcesByFunc returns all resources that the quota system should recognize. It requires a resource supports the following verbs: 'create','list','delete' This function may return both results and an error. If that happens, it means that the discovery calls were only partially successful. A decision about whether to proceed or not is left to the caller.
func RecommendedDefaultResourceQuotaControllerConfiguration ¶ added in v0.2.3
func RecommendedDefaultResourceQuotaControllerConfiguration(obj *kubectrlmgrconfigv1alpha1.ResourceQuotaControllerConfiguration)
RecommendedDefaultResourceQuotaControllerConfiguration defaults a pointer to a ResourceQuotaControllerConfiguration struct. This will set the recommended default values, but they may be subject to change between API versions. This function is intentionally not registered in the scheme as a "normal" `SetDefaults_Foo` function to allow consumers of this type to set whatever defaults for their embedded configs. Forcing consumers to use these defaults would be problematic as defaulting in the scheme is done as part of the conversion, and there would be no easy way to opt-out. Instead, if you want to use this defaulting method run it in your wrapper struct of this type in its `SetDefaults_` method.
func Register ¶ added in v0.2.3
func Register(ctrlCtx *controllers.Context) error
Register registers the quota controller
Types ¶
type AccountQuotaController ¶
type AccountQuotaController struct {
// contains filtered or unexported fields
}
AccountQuotaController is responsible for tracking quota usage status in the system
func NewAccountQuotaController ¶
func NewAccountQuotaController(options *AccountQuotaControllerOptions) (*AccountQuotaController, error)
NewAccountQuotaController creates a quota controller with specified options
func (*AccountQuotaController) Run ¶
func (rq *AccountQuotaController) Run(workers int, stopCh <-chan struct{})
Run begins quota controller using the specified number of workers
func (*AccountQuotaController) Sync ¶
func (rq *AccountQuotaController) Sync(discoveryFunc NamespacedResourcesFunc, period time.Duration, stopCh <-chan struct{})
Sync periodically resyncs the controller when new resources are observed from discovery.
type AccountQuotaControllerOptions ¶
type AccountQuotaControllerOptions struct { // Manager is needed for kubernetes access and cache Manager manager.Manager // Controls full recalculation of quota usage ResyncPeriod ResyncPeriodFunc // Maintains evaluators that know how to calculate usage for group resource Registry v12.Registry // Discover list of supported resources on the server. DiscoveryFunc NamespacedResourcesFunc // A function that returns the list of resources to ignore IgnoredResourcesFunc func() map[schema.GroupResource]struct{} // InformersStarted knows if informers were started. InformersStarted <-chan struct{} // InformerFactory interfaces with informers. InformerFactory controller.InformerFactory // Controls full resync of objects monitored for replenishment. ReplenishmentResyncPeriod ResyncPeriodFunc }
AccountQuotaControllerOptions holds options for creating a quota controller
type NamespacedResourcesFunc ¶
type NamespacedResourcesFunc func() ([]*metav1.APIResourceList, error)
NamespacedResourcesFunc knows how to discover namespaced resources.
type QuotaMonitor ¶
type QuotaMonitor struct {
// contains filtered or unexported fields
}
func (*QuotaMonitor) IsSynced ¶
func (qm *QuotaMonitor) IsSynced() bool
IsSynced returns true if any monitors exist AND all those monitors' controllers HasSynced functions return true. This means IsSynced could return true at one time, and then later return false if all monitors were reconstructed.
func (*QuotaMonitor) Run ¶
func (qm *QuotaMonitor) Run(stopCh <-chan struct{})
Run sets the stop channel and starts monitor execution until stopCh is closed. Any running monitors will be stopped before Run returns.
func (*QuotaMonitor) StartMonitors ¶
func (qm *QuotaMonitor) StartMonitors()
StartMonitors ensures the current set of monitors are running. Any newly started monitors will also cause shared informers to be started.
If called before Run, StartMonitors does nothing (as there is no stop channel to support monitor/informer execution).
func (*QuotaMonitor) SyncMonitors ¶
func (qm *QuotaMonitor) SyncMonitors(resources map[schema.GroupVersionResource]struct{}) error
SyncMonitors rebuilds the monitor set according to the supplied resources, creating or deleting monitors as necessary. It will return any error encountered, but will make an attempt to create a monitor for each resource instead of immediately exiting on an error. It may be called before or after Run. Monitors are NOT started as part of the sync. To ensure all existing monitors are started, call StartMonitors.
type ReplenishmentFunc ¶
type ReplenishmentFunc func(groupResource schema.GroupResource, namespace string)
ReplenishmentFunc is a signal that a resource changed in specified namespace that may require quota to be recalculated.
type ResyncPeriodFunc ¶
func StaticResyncPeriodFunc ¶
func StaticResyncPeriodFunc(resyncPeriod time.Duration) ResyncPeriodFunc
StaticResyncPeriodFunc returns the resync period specified