Documentation ¶
Index ¶
- func Create(mgr ctrl.Manager, f *forest.Forest, maxReconciles int, useFakeClient bool) error
- func GVKFor(gr schema.GroupResource, allRes []*restmapper.APIGroupResources) (schema.GroupVersionKind, error)
- func GetAllResources(config *rest.Config) ([]*restmapper.APIGroupResources, error)
- func GetValidateMode(mode api.SynchronizationMode, log logr.Logger) api.SynchronizationMode
- type AnchorReconciler
- type ConfigReconciler
- type FakeDeleteCRDClient
- type HierarchyConfigReconciler
- type ObjectReconciler
- func (r *ObjectReconciler) GetGVK() schema.GroupVersionKind
- func (r *ObjectReconciler) GetMode() api.SynchronizationMode
- func (r *ObjectReconciler) GetNumPropagatedObjects() int
- func (r *ObjectReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *ObjectReconciler) SetMode(ctx context.Context, log logr.Logger, mode api.SynchronizationMode) error
- func (r *ObjectReconciler) SetupWithManager(mgr ctrl.Manager, maxReconciles int) error
- func (r *ObjectReconciler) SyncNamespace(ctx context.Context, log logr.Logger, ns string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create creates all reconcilers.
This function is called both from main.go as well as from the integ tests.
func GVKFor ¶
func GVKFor(gr schema.GroupResource, allRes []*restmapper.APIGroupResources) (schema.GroupVersionKind, error)
GVKFor searches the GR in apiserver and returns the mapping GVK. If the GR doesn't exist, return an empty GVK and the error.
func GetAllResources ¶
func GetAllResources(config *rest.Config) ([]*restmapper.APIGroupResources, error)
GetAllResources creates a discovery client to get all the resources for all groups from the apiserver.
func GetValidateMode ¶
func GetValidateMode(mode api.SynchronizationMode, log logr.Logger) api.SynchronizationMode
GetValidateMode returns a valid api.SynchronizationMode based on the given mode. Please see the comments of api.SynchronizationMode for currently supported modes. If mode is not set, it will be api.Propagate by default. Any unrecognized mode is treated as api.Ignore.
Types ¶
type AnchorReconciler ¶
type AnchorReconciler struct { client.Client Log logr.Logger // Affected is a channel of event.GenericEvent (see "Watching Channels" in // https://book-v1.book.kubebuilder.io/beyond_basics/controller_watches.html) that is used to // enqueue additional objects that need updating. Affected chan event.GenericEvent // contains filtered or unexported fields }
AnchorReconciler reconciles SubnamespaceAnchor CRs to make sure all the subnamespaces are properly maintained.
func (*AnchorReconciler) Reconcile ¶
Reconcile sets up some basic variables and then calls the business logic. It currently only handles the creation of the namespaces but no deletion or state reporting yet.
func (*AnchorReconciler) SetupWithManager ¶
func (r *AnchorReconciler) SetupWithManager(mgr ctrl.Manager) error
type ConfigReconciler ¶
type ConfigReconciler struct { client.Client Log logr.Logger Manager ctrl.Manager // Forest is the in-memory data structure that is shared with all other reconcilers. Forest *forest.Forest // Trigger is a channel of event.GenericEvent (see "Watching Channels" in // https://book-v1.book.kubebuilder.io/beyond_basics/controller_watches.html) // that is used to enqueue the singleton to trigger reconciliation. Trigger chan event.GenericEvent // HierarchyConfigUpdates is a channel of events used to update hierarchy configuration changes performed by // ObjectReconcilers. It is passed on to ObjectReconcilers for the updates. The ConfigReconciler itself does // not use it. HierarchyConfigUpdates chan event.GenericEvent // contains filtered or unexported fields }
ConfigReconciler is responsible for determining the HNC configuration from the HNCConfiguration CR, as well as ensuring all objects are propagated correctly when the HNC configuration changes. It can also set the status of the HNCConfiguration CR.
func (*ConfigReconciler) SetupWithManager ¶
func (r *ConfigReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager builds a controller with the reconciler.
type FakeDeleteCRDClient ¶
type FakeDeleteCRDClient struct{}
FakeDeleteCRDClient is a "fake" client used for testing only
func (FakeDeleteCRDClient) Get ¶
func (f FakeDeleteCRDClient) Get(context.Context, types.NamespacedName, client.Object) error
FakeDeleteCRDClient doesn't return any err on Get() because none of the reconciler test performs CRD deletion
type HierarchyConfigReconciler ¶
type HierarchyConfigReconciler struct { client.Client Log logr.Logger // Forest is the in-memory data structure that is shared with all other reconcilers. // HierarchyConfigReconciler is responsible for keeping it up-to-date, but the other reconcilers // use it to determine how to propagate objects. Forest *forest.Forest // Affected is a channel of event.GenericEvent (see "Watching Channels" in // https://book-v1.book.kubebuilder.io/beyond_basics/controller_watches.html) that is used to // enqueue additional namespaces that need updating. Affected chan event.GenericEvent // contains filtered or unexported fields }
HierarchyConfigReconciler is responsible for determining the forest structure from the Hierarchy CRs, as well as ensuring all objects in the forest are propagated correctly when the hierarchy changes. It can also set the status of the Hierarchy CRs, as well as (in rare cases) override part of its spec (i.e., if a parent namespace no longer exists).
func (*HierarchyConfigReconciler) Reconcile ¶
func (r *HierarchyConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile sets up some basic variables and then calls the business logic.
func (*HierarchyConfigReconciler) SetupWithManager ¶
func (r *HierarchyConfigReconciler) SetupWithManager(mgr ctrl.Manager, maxReconciles int) error
type ObjectReconciler ¶
type ObjectReconciler struct { client.Client EventRecorder record.EventRecorder Log logr.Logger // Forest is the in-memory forest managed by the HierarchyConfigReconciler. Forest *forest.Forest // GVK is the group/version/kind handled by this reconciler. GVK schema.GroupVersionKind // Mode describes propagation mode of objects that are handled by this reconciler. // See more details in the comments of api.SynchronizationMode. Mode api.SynchronizationMode // Affected is a channel of event.GenericEvent (see "Watching Channels" in // https://book-v1.book.kubebuilder.io/beyond_basics/controller_watches.html) that is used to // enqueue additional objects that need updating. Affected chan event.GenericEvent // AffectedNamespace is a channel of events used to update namespaces. AffectedNamespace chan event.GenericEvent // contains filtered or unexported fields }
ObjectReconciler reconciles generic propagated objects. You must create one for each group/version/kind that needs to be propagated and set its `GVK` field appropriately.
func (*ObjectReconciler) GetGVK ¶
func (r *ObjectReconciler) GetGVK() schema.GroupVersionKind
GetGVK provides GVK that is handled by this reconciler.
func (*ObjectReconciler) GetMode ¶
func (r *ObjectReconciler) GetMode() api.SynchronizationMode
GetMode provides the mode of objects that are handled by this reconciler.
func (*ObjectReconciler) GetNumPropagatedObjects ¶
func (r *ObjectReconciler) GetNumPropagatedObjects() int
GetNumPropagatedObjects returns the number of propagated objects of the GVK handled by this object reconciler.
func (*ObjectReconciler) SetMode ¶
func (r *ObjectReconciler) SetMode(ctx context.Context, log logr.Logger, mode api.SynchronizationMode) error
SetMode sets the Mode field of an object reconciler and syncs objects in the cluster if needed. The method will return an error if syncs fail.
func (*ObjectReconciler) SetupWithManager ¶
func (r *ObjectReconciler) SetupWithManager(mgr ctrl.Manager, maxReconciles int) error
func (*ObjectReconciler) SyncNamespace ¶
SyncNamespace can be called manually by the HierarchyConfigReconciler when the hierarchy changes. It enqueues all the current objects in the namespace and local copies of the original objects in the ancestors.