Documentation
¶
Overview ¶
Package controller offers embeddable structs for use in your controller and underlying reconcilers, to help with conforming to GitOps Toolkit conventions.
Index ¶
- Variables
- func GetDefaultRateLimiter() workqueue.TypedRateLimiter[reconcile.Request]
- func GetRateLimiter(opts RateLimiterOptions) workqueue.TypedRateLimiter[reconcile.Request]
- func GetWatchLabelSelector(opts WatchOptions) (*metav1.LabelSelector, error)
- func GetWatchSelector(opts WatchOptions) (labels.Selector, error)
- type ConnectionOptions
- type Metrics
- func (m Metrics) DeleteCondition(ctx context.Context, obj conditions.Getter, conditionType string)
- func (m Metrics) IsDelete(obj conditions.Getter) bool
- func (m Metrics) RecordCondition(ctx context.Context, obj conditions.Getter, conditionType string)
- func (m Metrics) RecordDuration(ctx context.Context, obj conditions.Getter, startTime time.Time)
- func (m Metrics) RecordReadiness(ctx context.Context, obj conditions.Getter)
- func (m Metrics) RecordReconciling(ctx context.Context, obj conditions.Getter)
- func (m Metrics) RecordStalled(ctx context.Context, obj conditions.Getter)
- func (m Metrics) RecordSuspend(ctx context.Context, obj conditions.Getter, suspend bool)
- type RateLimiterOptions
- type WatchOptions
Constants ¶
This section is empty.
Variables ¶
var ErrInsecureHTTPBlocked = errors.New("use of insecure plain HTTP connections is blocked")
ErrInsecureHTTPBlocked signals that the use of insecure plain HTTP connections was requested but such behavior is blocked.
Functions ¶
func GetDefaultRateLimiter ¶ added in v0.26.0
func GetDefaultRateLimiter() workqueue.TypedRateLimiter[reconcile.Request]
GetDefaultRateLimiter returns a new exponential failure workqueue.TypedRateLimiter with the default configuration.
func GetRateLimiter ¶ added in v0.14.0
func GetRateLimiter(opts RateLimiterOptions) workqueue.TypedRateLimiter[reconcile.Request]
GetRateLimiter returns a new exponential failure workqueue.TypedRateLimiter based on RateLimiterOptions.
func GetWatchLabelSelector ¶ added in v0.34.0
func GetWatchLabelSelector(opts WatchOptions) (*metav1.LabelSelector, error)
GetWatchLabelSelector parses the label selector option from WatchOptions and returns an error if the expression is invalid.
func GetWatchSelector ¶ added in v0.34.0
func GetWatchSelector(opts WatchOptions) (labels.Selector, error)
GetWatchSelector parses the label selector option from WatchOptions and returns the label selector. If the WatchOptions contain no selectors, then a match everything is returned.
Types ¶
type ConnectionOptions ¶ added in v0.39.0
type ConnectionOptions struct { // AllowHTTP, if set to true allows the controller to make plain HTTP // connections to external services. AllowHTTP bool }
ConnectionOptions defines the configurable options for outbound connections opened by reconcilers. Consumers are expected to check for compatibility via `CheckEnvironmentCompatibility()` before using its values.
func (*ConnectionOptions) BindFlags ¶ added in v0.39.0
func (o *ConnectionOptions) BindFlags(fs *pflag.FlagSet)
BindFlags will parse the given pflag.FlagSet for the controller and set the ConnectionOptions accordingly.
func (*ConnectionOptions) CheckEnvironmentCompatibility ¶ added in v0.40.0
func (o *ConnectionOptions) CheckEnvironmentCompatibility() error
CheckEnvironmentCompatibility checks if the environment is compatible with the configured connection options.
type Metrics ¶
type Metrics struct { Scheme *runtime.Scheme MetricsRecorder *metrics.Recorder // contains filtered or unexported fields }
Metrics is a helper struct that adds the capability for recording GitOps Toolkit standard metrics to a reconciler.
Use it by embedding it in your reconciler struct:
type MyTypeReconciler { client.Client // ... etc. controller.Metrics }
Following the GitOps Toolkit conventions, API types used in GOTK SHOULD implement conditions.Getter to work with status condition types, and this convention MUST be followed to be able to record metrics using this helper.
Use MustMakeMetrics to create a working Metrics value; you can supply the same value to all reconcilers.
Once initialised, metrics can be recorded by calling one of the available `Record*` methods.
func NewMetrics ¶ added in v0.42.0
NewMetrics creates a new Metrics with the given metrics.Recorder, and the Metrics.Scheme set to that of the given mgr, along with an optional set of owned finalizers which is used to determine when an object is being deleted.
func (Metrics) DeleteCondition ¶ added in v0.42.0
DeleteCondition deletes the condition metrics of the given conditionType for the given object.
func (Metrics) IsDelete ¶ added in v0.42.0
func (m Metrics) IsDelete(obj conditions.Getter) bool
IsDelete returns if the object is deleted by checking for deletion timestamp and owned finalizers in the object.
func (Metrics) RecordCondition ¶ added in v0.13.0
RecordCondition records the status of the given conditionType for the given obj.
func (Metrics) RecordDuration ¶
RecordDuration records the duration of a reconcile attempt for the given obj based on the given startTime.
func (Metrics) RecordReadiness ¶ added in v0.13.0
func (m Metrics) RecordReadiness(ctx context.Context, obj conditions.Getter)
RecordReadiness records the meta.ReadyCondition status for the given obj.
func (Metrics) RecordReconciling ¶ added in v0.13.0
func (m Metrics) RecordReconciling(ctx context.Context, obj conditions.Getter)
RecordReconciling records the meta.ReconcilingCondition status for the given obj.
func (Metrics) RecordStalled ¶ added in v0.13.0
func (m Metrics) RecordStalled(ctx context.Context, obj conditions.Getter)
RecordStalled records the meta.StalledCondition status for the given obj.
func (Metrics) RecordSuspend ¶
RecordSuspend records the suspension of the given obj based on the given suspend value.
type RateLimiterOptions ¶ added in v0.14.0
type RateLimiterOptions struct { // MinRetryDelay represents the minimum amount of time in which an // object being reconciled will have to wait before a retry. MinRetryDelay time.Duration // MaxRetryDelay represents the maximum amount of time in which an // object being reconciled will have to wait before a retry. MaxRetryDelay time.Duration }
RateLimiterOptions defines the configurable options for rate limiters used on reconcilers.
func (*RateLimiterOptions) BindFlags ¶ added in v0.14.0
func (o *RateLimiterOptions) BindFlags(fs *pflag.FlagSet)
BindFlags will parse the given pflag.FlagSet for the controller and set the RateLimiterOptions accordingly.
type WatchOptions ¶ added in v0.34.0
type WatchOptions struct { // AllNamespaces defines the watch filter at namespace level. // If set to false, the reconciler will only watch the runtime namespace for resource changes. AllNamespaces bool // LabelSelector defines the watch filter based on matching label expressions. // When set, the reconciler will only watch for changes of those resources with matching labels. // Docs: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#list-and-watch-filtering. LabelSelector string }
WatchOptions defines the configurable options for reconciler resources watcher.
func (*WatchOptions) BindFlags ¶ added in v0.34.0
func (o *WatchOptions) BindFlags(fs *pflag.FlagSet)
BindFlags will parse the given pflag.FlagSet for the controller and set the WatchOptions accordingly.