Documentation ¶
Overview ¶
Package controller offers embeddable structs for use in your controller and underlying reconcilers, to help with conforming to GitOps Toolkit conventions.
Index ¶
- type Events
- func (e Events) Event(ctx context.Context, obj client.Object, severity, reason, msg string)
- func (e Events) EventWithMeta(ctx context.Context, obj client.Object, metadata map[string]string, ...)
- func (e Events) EventWithMetaf(ctx context.Context, obj client.Object, metadata map[string]string, ...)
- func (e Events) Eventf(ctx context.Context, obj client.Object, severity, reason, msgFmt string, ...)
- type Metrics
- 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)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Events ¶
type Events struct { Scheme *runtime.Scheme EventRecorder kuberecorder.EventRecorder ExternalEventRecorder *events.Recorder }
Events is a helper struct that adds the capability of sending events to the Kubernetes API and an external event recorder, like the GitOps Toolkit notification-controller.
Use it by embedding it in your reconciler struct:
type MyTypeReconciler { client.Client // ... etc. controller.Events }
Use MakeEvents to create a working Events value; in most cases the value needs to be initialised just once per controller, as the specialised logger and object reference data are gathered from the arguments provided to the Eventf method.
func MakeEvents ¶
MakeEvents creates a new Events, with the Events.Scheme set to that of the given mgr and a newly initialised Events.EventRecorder for the given controllerName.
func (Events) Event ¶
Event emits a Kubernetes event, and forwards the event to the ExternalEventRecorder if configured. Use EventWithMeta or EventWithMetaf if you want to attach metadata to the external event.
func (Events) EventWithMeta ¶
func (e Events) EventWithMeta(ctx context.Context, obj client.Object, metadata map[string]string, severity, reason, msg string)
EventWithMeta emits a Kubernetes event, and forwards the event and metadata to the ExternalEventRecorder if configured.
func (Events) EventWithMetaf ¶
func (e Events) EventWithMetaf(ctx context.Context, obj client.Object, metadata map[string]string, severity, reason, msgFmt string, args ...interface{})
EventWithMetaf emits a Kubernetes event, and forwards the event and metadata to the ExternalEventRecorder if configured.
func (Events) Eventf ¶
func (e Events) Eventf(ctx context.Context, obj client.Object, severity, reason, msgFmt string, args ...interface{})
Eventf emits a Kubernetes event, and forwards the event to the ExternalEventRecorder if configured. Use EventWithMeta or EventWithMetaf if you want to attach metadata to the external event.
type Metrics ¶
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 MustMakeMetrics ¶
MustMakeMetrics creates a new Metrics with a new metrics.Recorder, and the Metrics.Scheme set to that of the given mgr. It attempts to register the metrics collectors in the controller-runtime metrics registry, which panics upon the first registration that causes an error. Which usually happens if you try to initialise a Metrics value twice for your controller.
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.