controller

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: Apache-2.0 Imports: 14 Imported by: 25

Documentation

Overview

Package controller offers embeddable structs for putting in your controller, to help with conforming to GitOps Toolkit conventions.

Index

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 to the GitOps Toolkit notification controller. You use it by embedding it in your reconciler struct:

type MyTypeReconciler {
    client.Client
    // ... etc.
    controller.Events
}

You initialise a suitable value with MakeEvents; in most cases the value only needs to be initialized once per controller, as the specialised logger and object reference data are gathered from the arguments provided to the Eventf method.

func MakeEvents

func MakeEvents(mgr ctrl.Manager, controllerName string, ext *events.Recorder) Events

func (Events) Event

func (e Events) Event(ctx context.Context, obj runtimeAndMetaObject, metadata map[string]string, severity, reason, msg string)

Event emits a Kubernetes event, and forwards the event to the notification controller if configured.

func (Events) Eventf

func (e Events) Eventf(ctx context.Context, obj runtimeAndMetaObject, metadata map[string]string, severity, reason, msgFmt string, args ...interface{})

Eventf emits a Kubernetes event, and forwards the event to the notification controller if configured.

type Metrics

type Metrics struct {
	Scheme          *runtime.Scheme
	MetricsRecorder *metrics.Recorder
}

Metrics adds the capability for recording GOTK-standard metrics to a reconciler. Use by embedding into the reconciler struct:

type MyTypeReconciler struct {
  client.Client
  // ...
  controller.Metrics
}

then you can call either or both of RecordDuration and RecordReadinessMetric. API types used in GOTK will usually already be suitable for passing (as a pointer) as the second argument to `RecordReadinessMetric`.

When initialising controllers in main.go, use MustMakeMetrics to create a working Metrics value; you can supply the same value to all reconcilers.

func MustMakeMetrics

func MustMakeMetrics(mgr ctrl.Manager) Metrics

func (Metrics) RecordConditionMetric

func (m Metrics) RecordConditionMetric(ctx context.Context, obj readinessMetricsable, conditionType string)

func (Metrics) RecordDuration

func (m Metrics) RecordDuration(ctx context.Context, obj readinessMetricsable, startTime time.Time)

func (Metrics) RecordReadinessMetric

func (m Metrics) RecordReadinessMetric(ctx context.Context, obj readinessMetricsable)

func (Metrics) RecordSuspend

func (m Metrics) RecordSuspend(ctx context.Context, obj readinessMetricsable, suspend bool)

Jump to

Keyboard shortcuts

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