Documentation
¶
Overview ¶
Package controllers implements the lazy loader logic for Katanomi.
Package controllers implements the lazy loader logic for Katanomi.
Package controllers implements the lazy loader logic for Katanomi.
Index ¶
- Constants
- func ApplyControllerBuilderOptions(builder *builder.Builder, funcs ...ControllerBuilderOption) *builder.Builder
- func BuilderOptions(opts ...BuilderOptionFunc) controller.Options
- func CreateOrGetWithRetry(ctx context.Context, clt client.Client, obj client.Object) error
- func DefaultOptions() controller.Options
- func DefaultRateLimiter() workqueue.RateLimiter
- func DefaultTypedRateLimiter[T comparable]() workqueue.TypedRateLimiter[T]
- func GetNumRequeues(ctx context.Context) int
- func HasControllerReferenceByObjectReference(obj metav1.Object, ref *corev1.ObjectReference, controller bool) bool
- func NewReconcilerWrapper(r reconcile.Reconciler, opts ...WrapperOption) reconcile.Reconciler
- func RateLimiterCtx(ctx context.Context) workqueue.RateLimiter
- func ReconcileRequestCtx(ctx context.Context) ctrl.Request
- func TypedRateLimiter[T comparable](baseDelay time.Duration, maxDelay time.Duration) workqueue.TypedRateLimiter[T]
- func WithNumRequeues(ctx context.Context, num int) context.Context
- func WithRateLimiter(ctx context.Context, rl workqueue.RateLimiter) context.Context
- func WithReconcileRequest(ctx context.Context, key ctrl.Request) context.Context
- type AnnotationChangedPredicate
- type BuilderOptionFunc
- type ControllerBuilderOption
- type ControllerChecker
- type ControllerManager
- type DependencyCheckerInterface
- type EventRecorder
- func (recorder *EventRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, ...)
- func (recorder *EventRecorder) Event(object runtime.Object, eventtype, reason, message string)
- func (recorder *EventRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, ...)
- type Interface
- type LazyLoader
- type RequestFunc
- type ResultFunc
- type SecretDataChangedPredicate
- type SetupChecker
- type WrapperOption
- type WrapperOptions
Constants ¶
const DefaultMaxConcurrentReconciles = 10
DefaultMaxConcurrentReconciles is the default number of max concurrent reconciles
const (
// MessageShortenLength default message shorten length in event
MessageShortenLength = 1000
)
Variables ¶
This section is empty.
Functions ¶
func ApplyControllerBuilderOptions ¶
func ApplyControllerBuilderOptions(builder *builder.Builder, funcs ...ControllerBuilderOption) *builder.Builder
ApplyControllerBuilderOptions applies the given options to the controller builder
func BuilderOptions ¶
func BuilderOptions(opts ...BuilderOptionFunc) controller.Options
BuilderOptions returns a functional set of options with conservative defaults.
func CreateOrGetWithRetry ¶
CreateOrGetWithRetry will retry to create source multi times if encounter error however if error is alreadyExist then will get the resource and return it
func DefaultOptions ¶
func DefaultOptions() controller.Options
DefaultOptions returns the default options for the controller
func DefaultRateLimiter ¶
func DefaultRateLimiter() workqueue.RateLimiter
DefaultRateLimiter returns a workqueue rate limiter with a starting value of 2 seconds opposed to controller-runtime's default one of 1 millisecond Deprecated: DefaultRateLimiter is deprecated, use DefaultTypedRateLimiter instead.
func DefaultTypedRateLimiter ¶
func DefaultTypedRateLimiter[T comparable]() workqueue.TypedRateLimiter[T]
DefaultTypedRateLimiter returns a workqueue rate limiter with a starting value of 2 seconds opposed to controller-runtime's default one of 1 millisecond
func GetNumRequeues ¶
GetNumRequeues gets numRequeue from the context
func HasControllerReferenceByObjectReference ¶
func HasControllerReferenceByObjectReference(obj metav1.Object, ref *corev1.ObjectReference, controller bool) bool
HasControllerReferenceByObjectReference has controller owner reference
func NewReconcilerWrapper ¶
func NewReconcilerWrapper(r reconcile.Reconciler, opts ...WrapperOption) reconcile.Reconciler
NewReconcilerWrapper creates a new scheduleReconciler with the provided Reconciler and ScheduleOptions.
func RateLimiterCtx ¶
func RateLimiterCtx(ctx context.Context) workqueue.RateLimiter
RateLimiterCtx retrieves a RateLimiter from context. Returns nil if none
func ReconcileRequestCtx ¶
ReconcileRequestCtx retrieves a Request key from context returns an empty object if none
func TypedRateLimiter ¶
func TypedRateLimiter[T comparable](baseDelay time.Duration, maxDelay time.Duration) workqueue.TypedRateLimiter[T]
TypedRateLimiter returns a workqueue rate limiter with value of baseDelay and maxDelay opposed to controller-runtime's default one of 1 millisecond
func WithNumRequeues ¶
WithNumRequeues adds the numRequeues to the context
func WithRateLimiter ¶
WithRateLimiter stores a RateLimiter into context
Types ¶
type AnnotationChangedPredicate ¶
type AnnotationChangedPredicate struct { // Keys is a list of annotation keys to watch for changes. // If empty, all annotation changes will be considered. Keys []string predicate.AnnotationChangedPredicate }
AnnotationChangedPredicate implements a predicate that checks for changes in specific annotations. It extends the default AnnotationChangedPredicate from controller-runtime and allows filtering on specific annotation keys.
func (AnnotationChangedPredicate) Create ¶
func (p AnnotationChangedPredicate) Create(e event.CreateEvent) bool
Create implements Predicate interface for creation events. It checks if any of the specified annotation keys have changed from nil to a value.
func (AnnotationChangedPredicate) Delete ¶
func (p AnnotationChangedPredicate) Delete(e event.DeleteEvent) bool
Delete implements Predicate interface for deletion events. It checks if any of the specified annotation keys have changed from a value to nil.
func (AnnotationChangedPredicate) Generic ¶
func (p AnnotationChangedPredicate) Generic(e event.GenericEvent) bool
Generic implements Predicate interface for generic events. It checks if any of the specified annotation keys have changed.
func (AnnotationChangedPredicate) Update ¶
func (p AnnotationChangedPredicate) Update(e event.UpdateEvent) bool
Update implements Predicate interface for update events. It checks if any of the specified annotation keys have different values between old and new objects.
type BuilderOptionFunc ¶
type BuilderOptionFunc func(options controller.Options) controller.Options
BuilderOptionFunc is a function that can be used to configure the controller builder options
func MaxConCurrentReconciles ¶
func MaxConCurrentReconciles(num int) BuilderOptionFunc
MaxConCurrentReconciles sets the max concurrent reconciles
func RateLimiter ¶
func RateLimiter(rl workqueue.TypedRateLimiter[reconcile.Request]) BuilderOptionFunc
RateLimiter sets the rate limiter
type ControllerBuilderOption ¶
ControllerBuilderOption is a function that can be used to configure the controller builder
func WithBuilderOptions ¶
func WithBuilderOptions(opts controller.Options) ControllerBuilderOption
WithBuilderOptions returns a ControllerBuilderOption that applies the given options to the controller builder
type ControllerChecker ¶
type ControllerChecker interface { DependencyCheckerInterface SetupChecker }
type ControllerManager ¶
ControllerManager is just like sigs.k8s.io/controller-runtime.Manager and decorate GetEventRecorderFor function to shorten message length
func (ControllerManager) GetEventRecorderFor ¶
func (m ControllerManager) GetEventRecorderFor(name string) cliengorecord.EventRecorder
GetEventRecorderFor is just like sigs.k8s.io/controller-runtime.Manager.GetEventRecorderFor but will return EventRecorder that could shorten message length
type DependencyCheckerInterface ¶
type DependencyCheckerInterface interface {
DependentCrdInstalled(ctx context.Context, logger *zap.SugaredLogger) (bool, error)
}
DependencyCheckerInterface is the interface for checking dependencies
type EventRecorder ¶
type EventRecorder struct { cliengorecord.EventRecorder // MessageShortenLen indicates max event message length, it will be shortened if length is more than MessageShortenLen MessageShortenLen int }
EventRecorder is just like k8s.io/client-go/tools/record.EventRecorder, but will shorten message length according to MessageShortenLen
func (*EventRecorder) AnnotatedEventf ¶
func (recorder *EventRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})
AnnotatedEventf is same as k8s.io/client-go/tools/record.EventRecorder.Eventf, just shorten args filed if the field type is Stringer or Error
type Interface ¶
type Interface interface { Name() string Setup(context.Context, manager.Manager, *zap.SugaredLogger) error }
Interface is a basic interface that every reconciler should implement to create a new controller and startup in the controller manager
type LazyLoader ¶
type LazyLoader interface { LazyLoad(context.Context, manager.Manager, *zap.SugaredLogger, SetupChecker) error Start(context.Context) error }
LazyLoader loads whenever dependencies are ready
func NewLazyLoader ¶
func NewLazyLoader(ctx context.Context, interval time.Duration) LazyLoader
NewLazyLoader constructs new LazyLoader for controllers
type RequestFunc ¶
type ResultFunc ¶
type ResultFunc func(ctx context.Context, request reconcile.Request, result *reconcile.Result) error
func SyncPeriodResultFunc ¶
func SyncPeriodResultFunc(manager *config.Manager, configKey string) ResultFunc
SyncPeriodResultFunc contruct reconcile.Result to requeue automatically the RequeueAfter value is set by configKey in `FeatureFlag`
type SecretDataChangedPredicate ¶
SecretDataChangedPredicate implements a default update predicate function on secret data change.
func (SecretDataChangedPredicate) Update ¶
func (SecretDataChangedPredicate) Update(e event.UpdateEvent) bool
Update implements default UpdateEvent filter for validating generation change.
type SetupChecker ¶
type SetupChecker interface { Interface CheckSetup(context.Context, manager.Manager, *zap.SugaredLogger) error }
SetupChecker controllers with dependencies on other resources will need to implement this interface to allow lazy loading
type WrapperOption ¶
type WrapperOption func(*WrapperOptions)
type WrapperOptions ¶
type WrapperOptions struct { // define the synchronization interval. RequestFuncs []RequestFunc ResultFuncs []ResultFunc Object client.Object Client client.Client }