Documentation ¶
Index ¶
- func IsNamespaceScheduledToCluster(obj metav1.Object, clusterID string) error
- type Cache
- type ClusterInterface
- type Getter
- type MultiClusterController
- func (c *MultiClusterController) Eventf(clusterName string, ref *v1.ObjectReference, eventtype string, ...) error
- func (c *MultiClusterController) FilterObjectFromSchedulingResult(req reconciler.Request) bool
- func (c *MultiClusterController) Get(clusterName, namespace, name string) (interface{}, error)
- func (c *MultiClusterController) GetByObjectType(clusterName, namespace, name string, objectType runtime.Object) (interface{}, error)
- func (c *MultiClusterController) GetCluster(clusterName string) ClusterInterface
- func (c *MultiClusterController) GetClusterClient(clusterName string) (clientset.Interface, error)
- func (c *MultiClusterController) GetClusterNames() []string
- func (c *MultiClusterController) GetClusterObject(clusterName string) (runtime.Object, error)
- func (c *MultiClusterController) GetControllerName() string
- func (c *MultiClusterController) GetObjectKind() string
- func (c *MultiClusterController) GetOwnerInfo(clusterName string) (string, string, string, error)
- func (c *MultiClusterController) List(clusterName string, opts ...client.ListOption) (interface{}, error)
- func (c *MultiClusterController) ListByObjectType(clusterName string, objectType runtime.Object, opts ...client.ListOption) (interface{}, error)
- func (c *MultiClusterController) RegisterClusterResource(cluster ClusterInterface, o WatchOptions) error
- func (c *MultiClusterController) RequeueObject(clusterName string, obj interface{}) error
- func (c *MultiClusterController) Start(stop <-chan struct{}) error
- func (c *MultiClusterController) TeardownClusterResource(cluster ClusterInterface)
- func (c *MultiClusterController) WatchClusterResource(cluster ClusterInterface, o WatchOptions) error
- type OptConfig
- func WithControllerName(name string) OptConfig
- func WithJitterPeriod(t time.Duration) OptConfig
- func WithMaxConcurrentReconciles(n int) OptConfig
- func WithOptions(o *Options) OptConfig
- func WithReconciler(rc reconciler.DWReconciler) OptConfig
- func WithWorkQueue(q workqueue.RateLimitingInterface) OptConfig
- type Options
- type WatchOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClusterInterface ¶
type ClusterInterface interface { GetClusterName() string GetOwnerInfo() (string, string, string) GetObject() (runtime.Object, error) AddEventHandler(runtime.Object, clientgocache.ResourceEventHandler) error GetInformer(objectType runtime.Object) (cache.Informer, error) GetClientSet() (clientset.Interface, error) GetDelegatingClient() (client.Client, error) GetRestConfig() *rest.Config Cache }
ClusterInterface decouples the controller package from the cluster package.
type MultiClusterController ¶
MultiClusterController implements the multicluster controller pattern. A MultiClusterController owns a client-go workqueue. The WatchClusterResource methods set up the queue to receive reconcile requests, e.g., CRUD events from a tenant cluster. The Requests are processed by the user-provided Reconciler. MultiClusterController saves all watched tenant clusters in a set.
func NewMCController ¶
func NewMCController(objectType, objectListType runtime.Object, rc reconciler.DWReconciler, opts ...OptConfig) (*MultiClusterController, error)
NewMCController creates a new MultiClusterController.
func (*MultiClusterController) Eventf ¶
func (c *MultiClusterController) Eventf(clusterName string, ref *v1.ObjectReference, eventtype string, reason, messageFmt string, args ...interface{}) error
Eventf constructs an event from the given information and puts it in the queue for sending. 'ref' is the object this event is about. Event will make a reference or you may also pass a reference to the object directly. 'eventtype' of this event, and can be one of Normal, Warning. New types could be added in future 'reason' is the reason this event is generated. 'reason' should be short and unique; it should be in UpperCamelCase format (starting with a capital letter). "reason" will be used to automate handling of events, so imagine people writing switch statements to handle them. You want to make that easy. 'message' is intended to be human readable.
The resulting event will be created in the same namespace as the reference object.
func (*MultiClusterController) FilterObjectFromSchedulingResult ¶
func (c *MultiClusterController) FilterObjectFromSchedulingResult(req reconciler.Request) bool
func (*MultiClusterController) Get ¶
func (c *MultiClusterController) Get(clusterName, namespace, name string) (interface{}, error)
Get returns object with specific cluster, namespace and name.
func (*MultiClusterController) GetByObjectType ¶
func (c *MultiClusterController) GetByObjectType(clusterName, namespace, name string, objectType runtime.Object) (interface{}, error)
GetByObjectType returns object with specific cluster, namespace and name and object type
func (*MultiClusterController) GetCluster ¶
func (c *MultiClusterController) GetCluster(clusterName string) ClusterInterface
func (*MultiClusterController) GetClusterClient ¶
func (c *MultiClusterController) GetClusterClient(clusterName string) (clientset.Interface, error)
GetClusterClient returns the cluster's clientset client for direct access to tenant apiserver
func (*MultiClusterController) GetClusterNames ¶
func (c *MultiClusterController) GetClusterNames() []string
GetClusterNames returns the name list of all managed tenant clusters
func (*MultiClusterController) GetClusterObject ¶
func (c *MultiClusterController) GetClusterObject(clusterName string) (runtime.Object, error)
func (*MultiClusterController) GetControllerName ¶
func (c *MultiClusterController) GetControllerName() string
GetControllerName get the mccontroller name, is used to uniquely identify the Controller in tracing, logging and monitoring.
func (*MultiClusterController) GetObjectKind ¶
func (c *MultiClusterController) GetObjectKind() string
GetObjectKind is the objectKind name this controller watch to.
func (*MultiClusterController) GetOwnerInfo ¶
func (*MultiClusterController) List ¶
func (c *MultiClusterController) List(clusterName string, opts ...client.ListOption) (interface{}, error)
List returns a list of objects with specific cluster.
func (*MultiClusterController) ListByObjectType ¶
func (c *MultiClusterController) ListByObjectType(clusterName string, objectType runtime.Object, opts ...client.ListOption) (interface{}, error)
ListByObjectType returns a list of objects with specific cluster and object type.
func (*MultiClusterController) RegisterClusterResource ¶
func (c *MultiClusterController) RegisterClusterResource(cluster ClusterInterface, o WatchOptions) error
RegisterClusterResource get the informer *before* trying to wait for the caches to sync so that we have a chance to register their intended caches.
func (*MultiClusterController) RequeueObject ¶
func (c *MultiClusterController) RequeueObject(clusterName string, obj interface{}) error
RequeueObject requeues the cluster object, thus reconcileHandler can reconcile it again.
func (*MultiClusterController) Start ¶
func (c *MultiClusterController) Start(stop <-chan struct{}) error
Start starts the ClustersController's control loops (as many as MaxConcurrentReconciles) in separate channels and blocks until an empty struct is sent to the stop channel.
func (*MultiClusterController) TeardownClusterResource ¶
func (c *MultiClusterController) TeardownClusterResource(cluster ClusterInterface)
TeardownClusterResource forget the cluster it watches. The cluster informer should stop together.
func (*MultiClusterController) WatchClusterResource ¶
func (c *MultiClusterController) WatchClusterResource(cluster ClusterInterface, o WatchOptions) error
WatchClusterResource configures the Controller to watch resources of the same Kind as objectType, in the specified cluster, generating reconcile Requests from the ClusterInterface's context and the watched objects' namespaces and names.
type OptConfig ¶
type OptConfig func(*Options)
func WithControllerName ¶
WithControllerName set the controller name.
func WithJitterPeriod ¶
WithJitterPeriod set JitterPeriod.
func WithMaxConcurrentReconciles ¶
WithMaxConcurrentReconciles set MaxConcurrentReconciles if valid.
func WithReconciler ¶
func WithReconciler(rc reconciler.DWReconciler) OptConfig
WithReconciler set the reconciler.
func WithWorkQueue ¶
func WithWorkQueue(q workqueue.RateLimitingInterface) OptConfig
WithWorkQueue set the workqueue for mccontroller.
type Options ¶
type Options struct { // JitterPeriod is the time to wait after an error to start working again. JitterPeriod time.Duration // MaxConcurrentReconciles is the number of concurrent control loops. MaxConcurrentReconciles int Reconciler reconciler.DWReconciler // Queue can be used to override the default queue. Queue workqueue.RateLimitingInterface // contains filtered or unexported fields }
Options are the arguments for creating a new Controller.
type WatchOptions ¶
type WatchOptions struct {
AttachUID bool // the object UID will be added to the reconciler request if it is true
}
WatchOptions is used as an argument of WatchResource methods (just a placeholder for now). TODO: consider implementing predicates.