controllers

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

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

View Source
const DefaultMaxConcurrentReconciles = 10

DefaultMaxConcurrentReconciles is the default number of max concurrent reconciles

View Source
const (
	// MessageShortenLength default message shorten length in event
	MessageShortenLength = 1000
)

Variables

This section is empty.

Functions

func ApplyControllerBuilderOptions added in v0.9.0

func ApplyControllerBuilderOptions(builder *builder.Builder, funcs ...ControllerBuilderOption) *builder.Builder

ApplyControllerBuilderOptions applies the given options to the controller builder

func BuilderOptions added in v0.9.0

func BuilderOptions(opts ...BuilderOptionFunc) controller.Options

BuilderOptions returns a functional set of options with conservative defaults.

func CreateOrGetWithRetry added in v0.9.0

func CreateOrGetWithRetry(ctx context.Context, clt client.Client, obj client.Object) error

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 added in v0.9.0

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

func HasControllerReferenceByObjectReference

func HasControllerReferenceByObjectReference(obj metav1.Object, ref *corev1.ObjectReference, controller bool) bool

HasControllerReferenceByObjectReference has controller owner reference

func NewReconcilerWrapper added in v0.10.0

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

func ReconcileRequestCtx(ctx context.Context) ctrl.Request

ReconcileRequestCtx retrieves a Request key from context returns an empty object if none

func WithRateLimiter

func WithRateLimiter(ctx context.Context, rl workqueue.RateLimiter) context.Context

WithRateLimiter stores a RateLimiter into context

func WithReconcileRequest

func WithReconcileRequest(ctx context.Context, key ctrl.Request) context.Context

WithReconcileRequest stores a Request key into context

Types

type BuilderOptionFunc added in v0.9.0

type BuilderOptionFunc func(options controller.Options) controller.Options

BuilderOptionFunc is a function that can be used to configure the controller builder options

func MaxConCurrentReconciles added in v0.9.0

func MaxConCurrentReconciles(num int) BuilderOptionFunc

MaxConCurrentReconciles sets the max concurrent reconciles

func RateLimiter added in v0.9.0

RateLimiter sets the rate limiter

type ControllerBuilderOption added in v0.9.0

type ControllerBuilderOption func(*builder.Builder) *builder.Builder

ControllerBuilderOption is a function that can be used to configure the controller builder

func WithBuilderOptions added in v0.9.0

func WithBuilderOptions(opts controller.Options) ControllerBuilderOption

WithBuilderOptions returns a ControllerBuilderOption that applies the given options to the controller builder

type ControllerChecker added in v0.9.0

type ControllerChecker interface {
	DependencyCheckerInterface
	SetupChecker
}

type ControllerManager added in v0.10.0

type ControllerManager struct {
	ctrl.Manager
}

ControllerManager is just like sigs.k8s.io/controller-runtime.Manager and decorate GetEventRecorderFor function to shorten message length

func (ControllerManager) GetEventRecorderFor added in v0.10.0

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 added in v0.9.0

type DependencyCheckerInterface interface {
	DependentCrdInstalled(ctx context.Context, logger *zap.SugaredLogger) (bool, error)
}

DependencyCheckerInterface is the interface for checking dependencies

type EventRecorder added in v0.10.0

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 added in v0.10.0

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

func (*EventRecorder) Event added in v0.10.0

func (recorder *EventRecorder) Event(object runtime.Object, eventtype, reason, message string)

Event is same as k8s.io/client-go/tools/record.EventRecorder.Event, just shorten message filed

func (*EventRecorder) Eventf added in v0.10.0

func (recorder *EventRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

Eventf 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 added in v0.10.0

type RequestFunc func(ctx context.Context, request reconcile.Request) (context.Context, error)

type ResultFunc added in v0.10.0

type ResultFunc func(ctx context.Context, request reconcile.Request, result *reconcile.Result) error

func SyncPeriodResultFunc added in v0.10.0

func SyncPeriodResultFunc(manager *config.Manager, configKey string) ResultFunc

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 added in v0.10.0

type WrapperOption func(*WrapperOptions)

type WrapperOptions added in v0.10.0

type WrapperOptions struct {
	// define the synchronization interval.
	RequestFuncs []RequestFunc
	ResultFuncs  []ResultFunc
	Object       client.Object
	Client       client.Client
}

Jump to

Keyboard shortcuts

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