app

package
v0.0.0-...-0f541f5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ControllerStartJitter is the Jitter used when starting controller managers
	ControllerStartJitter = 1.0
	// ConfigzName is the name used for register firefly-controller manager /configz, same with GroupName.
	ConfigzName = "fireflycontrollermanager.config.firefly.io"
)

Variables

View Source
var ControllersDisabledByDefault = sets.NewString()

ControllersDisabledByDefault is the set of controllers which is disabled by default

Functions

func GetAvailableResources

func GetAvailableResources(client discovery.DiscoveryInterface) (map[schema.GroupVersionResource]bool, error)

GetAvailableResources gets the map which contains all available resources of the apiserver TODO: In general, any controller checking this needs to be dynamic so users don't have to restart their controller manager if they change the apiserver. Until we get there, the structure here needs to be exposed for the construction of a proper ControllerContext.

func GetHostClusterAvailableResources

func GetHostClusterAvailableResources(clientBuilder clientbuilder.FireflyControllerClientBuilder) (map[schema.GroupVersionResource]bool, error)

GetHostClusterAvailableResources gets the map which contains all available resources of the kube-apiserver on the host cluster. TODO: In general, any controller checking this needs to be dynamic so users don't have to restart their controller manager if they change the apiserver. Until we get there, the structure here needs to be exposed for the construction of a proper ControllerContext.

func GetKarmadaAvailableResources

func GetKarmadaAvailableResources(clientBuilder clientbuilder.KarmadaControllerClientBuilder) (map[schema.GroupVersionResource]bool, error)

GetKarmadaAvailableResources gets the map which contains all available resources of the karmada-apiserver TODO: In general, any controller checking this needs to be dynamic so users don't have to restart their controller manager if they change the apiserver. Until we get there, the structure here needs to be exposed for the construction of a proper ControllerContext.

func KnownControllers

func KnownControllers() []string

KnownControllers returns all known controllers's name

func NewControllerInitializers

func NewControllerInitializers() map[string]InitFunc

NewControllerInitializers is a public map of named controller groups (you can start more than one in an init func) paired to their InitFunc. This allows for structured downstream composition and subdivision.

func NewControllerManagerCommand

func NewControllerManagerCommand() *cobra.Command

NewControllerManagerCommand creates a *cobra.Command object with default parameters

func ResyncPeriod

func ResyncPeriod(c *config.CompletedConfig) func() time.Duration

ResyncPeriod returns a function which generates a duration each time it is invoked; this is so that multiple controllers don't get into lock-step and all hammer the apiserver with list requests simultaneously.

func Run

func Run(c *config.CompletedConfig, stopCh <-chan struct{}) error

Run runs the FireflyControllerManagerOptions.

func StartControllers

func StartControllers(ctx context.Context, controllerCtx ControllerContext, controllers map[string]InitFunc,
	unsecuredMux *mux.PathRecorderMux, healthzHandler *controllerhealthz.MutableHealthzHandler) error

StartControllers starts a set of controllers with a specified ControllerContext

Types

type ControllerContext

type ControllerContext struct {
	// KarmadaClientBuilder will provide a client for this controller to use
	KarmadaClientBuilder clientbuilder.KarmadaControllerClientBuilder

	// FireflyClientBuilder will provide a client for this controller to use
	FireflyClientBuilder clientbuilder.FireflyControllerClientBuilder

	// KarmadaKubeInformerFactory gives access to dynamic informers for the controller.
	KarmadaDynamicInformerFactory dynamicinformer.DynamicSharedInformerFactory

	// KarmadaKubeInformerFactory gives access to kubernetes informers for the controller.
	KarmadaKubeInformerFactory informers.SharedInformerFactory

	// KarmadaFireflyInformerFactory gives access to karmada's firelfy informers for the controller.
	KarmadaFireflyInformerFactory karmadafireflyinformers.SharedInformerFactory

	// KarmadaInformerFactory gives access to firefly informers for the controller.
	KarmadaInformerFactory karmadainformers.SharedInformerFactory

	// FireflyDynamicInformerFactory gives access to dynamic informers for the controller.
	FireflyDynamicInformerFactory dynamicinformer.DynamicSharedInformerFactory

	// FireflyKubeInformerFactory gives access to firefly informers for the controller.
	FireflyKubeInformerFactory informers.SharedInformerFactory

	// FireflyInformerFactory gives access to firefly informers for the controller.
	FireflyInformerFactory fireflyinformers.SharedInformerFactory

	// EstimatorNamespace is the namespace of scheduler-estimator
	EstimatorNamespace string
	// KarmadaName is the name of a firefly karmada object
	KarmadaName string

	// ObjectOrMetadataInformerFactory gives access to informers for typed resources
	// and dynamic resources by their metadata. All generic controllers currently use
	// object metadata - if a future controller needs access to the full object this
	// would become GenericInformerFactory and take a dynamic client.
	ObjectOrMetadataInformerFactory informerfactory.InformerFactory

	// ComponentConfig provides access to init options for a given controller
	ComponentConfig fireflyctrlmgrconfig.FireflyKarmadaManagerConfiguration

	// DeferredDiscoveryRESTMapper is a RESTMapper that will defer
	// initialization of the RESTMapper until the first mapping is
	// requested.
	RESTMapper *restmapper.DeferredDiscoveryRESTMapper

	// AvailableResources is a map listing currently available resources
	AvailableResources map[schema.GroupVersionResource]bool

	// HostClusterAvailableResources is a map listing currently available resources on the host cluster.
	HostClusterAvailableResources map[schema.GroupVersionResource]bool

	// InformersStarted is closed after all of the controllers have been initialized and are running.  After this point it is safe,
	// for an individual controller to start the shared informers. Before it is closed, they should not.
	InformersStarted chan struct{}

	// ResyncPeriod generates a duration each time it is invoked; this is so that
	// multiple controllers don't get into lock-step and all hammer the apiserver
	// with list requests simultaneously.
	ResyncPeriod func() time.Duration
}

ControllerContext defines the context object for controller

func CreateControllerContext

func CreateControllerContext(s *config.CompletedConfig, karmadaClientBuilder clientbuilder.KarmadaControllerClientBuilder, fireflyKubeClientBuilder clientbuilder.FireflyControllerClientBuilder, stop <-chan struct{}) (ControllerContext, error)

CreateControllerContext creates a context struct containing references to resources needed by the controllers such as the cloud provider and clientBuilder. rootClientBuilder is only used for the shared-informers client and token controller.

func (ControllerContext) IsControllerEnabled

func (c ControllerContext) IsControllerEnabled(name string) bool

IsControllerEnabled checks if the context's controllers enabled or not

type ControllerInitializersFunc

type ControllerInitializersFunc func() (initializers map[string]InitFunc)

ControllerInitializersFunc is used to create a collection of initializers.

type InitFunc

type InitFunc func(ctx context.Context, controllerCtx ControllerContext) (controller controller.Interface, enabled bool, err error)

InitFunc is used to launch a particular controller. It returns a controller that can optionally implement other interfaces so that the controller manager can support the requested features. The returned controller may be nil, which will be considered an anonymous controller that requests no additional features from the controller manager. Any error returned will cause the controller process to `Fatal` The bool indicates whether the controller was enabled.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL