Documentation
¶
Index ¶
- func IsNamespaceScheduledToCluster(obj client.Object, clusterID string) error
- type Cache
- type ClusterInterface
- type Getter
- type MultiClusterController
- func (c *MultiClusterController) Eventf(clusterName string, ref *corev1.ObjectReference, eventtype string, ...) error
- func (c *MultiClusterController) FilterObjectFromSchedulingResult(req reconciler.Request) bool
- func (c *MultiClusterController) Get(clusterName, namespace, name string, obj client.Object) 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) (client.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, instanceList client.ObjectList, opts ...client.ListOption) 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 MultiClusterInterface
- 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() (client.Object, error) AddEventHandler(client.Object, clientgocache.ResourceEventHandler) error GetInformer(objectType client.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 ¶
type MultiClusterController struct { sync.Mutex MultiClusterInterface Options // contains filtered or unexported fields }
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 client.Object, objectListType client.ObjectList, rc reconciler.DWReconciler, opts ...OptConfig) (*MultiClusterController, error)
NewMCController creates a new MultiClusterController.
func (*MultiClusterController) Eventf ¶
func (c *MultiClusterController) Eventf(clusterName string, ref *corev1.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, obj client.Object) error
Get returns object with specific cluster, namespace and name.
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) (client.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, instanceList client.ObjectList, opts ...client.ListOption) error
List returns a list of objects with specific cluster.
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 MultiClusterInterface ¶
type MultiClusterInterface interface { WatchClusterResource(cluster ClusterInterface, o WatchOptions) error RegisterClusterResource(cluster ClusterInterface, o WatchOptions) error TeardownClusterResource(cluster ClusterInterface) GetControllerName() string GetObjectKind() string Get(clusterName, namespace, name string, obj client.Object) error List(clusterName string, instanceList client.ObjectList, opts ...client.ListOption) error GetCluster(clusterName string) ClusterInterface GetClusterClient(clusterName string) (clientset.Interface, error) GetClusterObject(clusterName string) (client.Object, error) GetOwnerInfo(clusterName string) (string, string, string, error) GetClusterNames() []string }
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.