reconciler

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessPermissionAnnotation = "/access-permissions"
)
View Source
const LastAppliedAnnotation = "/last-applied-spec"

Variables

View Source
var (
	ApplyAwaitingVerification = ApplyResponse{Result: ApplyResultAwaitingVerification}
	ApplySucceeded            = ApplyResponse{Result: ApplyResultSucceeded}
	ApplyError                = ApplyResponse{Result: ApplyResultError}
)
View Source
var (
	VerifyError            = VerifyResponse{Result: VerifyResultError}
	VerifyMissing          = VerifyResponse{Result: VerifyResultMissing}
	VerifyRecreateRequired = VerifyResponse{Result: VerifyResultRecreateRequired}
	VerifyUpdateRequired   = VerifyResponse{Result: VerifyResultUpdateRequired}
	VerifyInProgress       = VerifyResponse{Result: VerifyResultInProgress}
	VerifyDeleting         = VerifyResponse{Result: VerifyResultDeleting}
	VerifyReady            = VerifyResponse{Result: VerifyResultReady}
)
View Source
var NoDependencies = DependencyDefinitions{
	Dependencies: []*Dependency{},
	Owner:        nil,
}

A shortcut for objects with no dependencies

Functions

This section is empty.

Types

type AccessPermissions

type AccessPermissions string

type ApplyResponse

type ApplyResponse struct {
	Result ApplyResult
	Status interface{}
}

The Result of a create or update operation, along with Status information, if present

func ApplyAwaitingVerificationWithStatus

func ApplyAwaitingVerificationWithStatus(status interface{}) ApplyResponse

func ApplySucceededWithStatus

func ApplySucceededWithStatus(status interface{}) ApplyResponse

type ApplyResult

type ApplyResult string

The Result of a create or update operation

const (
	ApplyResultAwaitingVerification ApplyResult = "AwaitingVerification"
	ApplyResultSucceeded            ApplyResult = "Succeeded"
	ApplyResultError                ApplyResult = "Error"
)

type CompletionRunner

type CompletionRunner interface {
	Run(ctx context.Context, r runtime.Object) error
}

A handler that is invoked after the resource has been successfully created and it has been verified to be ready for consumption (ReconcileState=Success) This is typically used for example to create secrets with authentication information

type DefinitionManager

type DefinitionManager interface {
	// returns a ResourceDefinition
	GetDefinition(ctx context.Context, namespacedName types.NamespacedName) *ResourceDefinition
	// returns the dependencies for a resource
	GetDependencies(ctx context.Context, thisInstance runtime.Object) (*DependencyDefinitions, error)
}

DefinitionManager is used to retrieve the required custom resource definitions and convert them into a state that can be consumed and updated (where applicable) generically

type DeleteResult

type DeleteResult string

The Result of a delete operation

const (
	DeleteAlreadyDeleted       DeleteResult = "AlreadyDeleted"
	DeleteSucceeded            DeleteResult = "Succeeded"
	DeleteAwaitingVerification DeleteResult = "AwaitingVerification"
	DeleteError                DeleteResult = "Error"
)

type Dependency

type Dependency struct {
	// This can be an empty resource definition object of the required Kind
	InitialInstance runtime.Object
	NamespacedName  types.NamespacedName
	// A function to return whether the object has been successfully applied. The current object will only
	// continue once this returns true for all dependencies
	SucceededAccessor SucceededAccessor
}

The information required to pull the resource definition of a dependency from kubernetes and determine whether it has been successfully applied or not

type DependencyDefinitions

type DependencyDefinitions struct {
	Owner        *Dependency
	Dependencies []*Dependency
}

Details of the owner and the dependencies of the resource

type GenericController

type GenericController struct {
	Parameters         ReconcileParameters
	ResourceKind       string
	KubeClient         client.Client
	Log                logr.Logger
	Recorder           record.EventRecorder
	Scheme             *runtime.Scheme
	ResourceManager    ResourceManager
	DefinitionManager  DefinitionManager
	FinalizerName      string
	AnnotationBaseName string
	CompletionRunner   func(*GenericController) CompletionRunner
}

GenericController is a generic implementation of a Kubebuilder controller

func CreateGenericController

func CreateGenericController(
	parameters ReconcileParameters,
	resourceKind string,
	kubeClient client.Client,
	logger logr.Logger,
	recorder record.EventRecorder,
	scheme *runtime.Scheme,
	resourceManager ResourceManager,
	defMgr DefinitionManager,
	finalizerName string,
	annotationBaseName string,
	completionRunner func(*GenericController) CompletionRunner) (*GenericController, error)

func (*GenericController) Reconcile

func (gc *GenericController) Reconcile(req ctrl.Request) (ctrl.Result, error)

type ReconcileParameters

type ReconcileParameters struct {
	RequeueAfter        int
	RequeueAfterSuccess int
	RequeueAfterFailure int
}

type ReconcileState

type ReconcileState string
const (
	Pending     ReconcileState = "Pending"
	Creating    ReconcileState = "Creating"
	Updating    ReconcileState = "Updating"
	Verifying   ReconcileState = "Verifying"
	Completing  ReconcileState = "Completing"
	Succeeded   ReconcileState = "Succeeded"
	Recreating  ReconcileState = "Recreating"
	Failed      ReconcileState = "Failed"
	Terminating ReconcileState = "Terminating"
)

type ResourceDefinition

type ResourceDefinition struct {
	// This can be an empty resource definition object of the required Kind
	InitialInstance runtime.Object
	// A function to get the Status of the kubernetes object
	StatusAccessor StatusAccessor
	// A function to update the Status of a kubernetes object instance
	StatusUpdater StatusUpdater
}

Details of the current resource being reconciled

type ResourceManager

type ResourceManager interface {
	// Creates an external resource, though it doesn't verify the readiness for consumption
	Create(context.Context, ResourceSpec) (ApplyResponse, error)
	// Updates an external resource
	Update(context.Context, ResourceSpec) (ApplyResponse, error)
	// Verifies the state of the external resource
	Verify(context.Context, ResourceSpec) (VerifyResponse, error)
	// Deletes external resource
	Delete(context.Context, ResourceSpec) (DeleteResult, error)
}

ResourceManager is a common abstraction for the controller to interact with external resources The ResourceManager cannot modify the runtime.Object kubernetes object it only needs to query or mutate the external resource, return the Result of the operation

type ResourceSpec

type ResourceSpec struct {
	Instance     runtime.Object
	Dependencies map[types.NamespacedName]runtime.Object
}

type Status

type Status struct {
	State         ReconcileState
	Message       string
	StatusPayload interface{}
}

func (*Status) IsCompleting

func (s *Status) IsCompleting() bool

func (*Status) IsCreating

func (s *Status) IsCreating() bool

func (*Status) IsFailed

func (s *Status) IsFailed() bool

func (*Status) IsPending

func (s *Status) IsPending() bool

func (*Status) IsRecreating

func (s *Status) IsRecreating() bool

func (*Status) IsSucceeded

func (s *Status) IsSucceeded() bool

func (*Status) IsTerminating

func (s *Status) IsTerminating() bool

func (*Status) IsUpdating

func (s *Status) IsUpdating() bool

func (*Status) IsVerifying

func (s *Status) IsVerifying() bool

type StatusAccessor

type StatusAccessor = func(instance runtime.Object) (*Status, error)

fetches the Status of the instance of runtime.Object

type StatusUpdater

type StatusUpdater = func(instance runtime.Object, status *Status) error

updates the Status of the instance of runtime.Object with Status

type SucceededAccessor

type SucceededAccessor = func(instance runtime.Object) (bool, error)

fetches a boolean flag to indicate whether the resource is in a succeeded (i.e. ready) state

func AsSuccessAccessor

func AsSuccessAccessor(s StatusAccessor) SucceededAccessor

unfortunately if doesn't seem possible to make this an extension method with a receiver unfortunately if doesn't seem possible to make this an extension method with a receiver

type VerifyResponse

type VerifyResponse struct {
	Result VerifyResult
	Status interface{}
}

func VerifyReadyWithStatus

func VerifyReadyWithStatus(status interface{}) VerifyResponse

type VerifyResult

type VerifyResult string

The Result of a verify operation

const (
	VerifyResultMissing          VerifyResult = "Missing"
	VerifyResultRecreateRequired VerifyResult = "RecreateRequired"
	VerifyResultUpdateRequired   VerifyResult = "UpdateRequired"
	VerifyResultInProgress       VerifyResult = "InProgress"
	VerifyResultDeleting         VerifyResult = "Deleting"
	VerifyResultReady            VerifyResult = "Ready"
	VerifyResultError            VerifyResult = "Error"
)

Jump to

Keyboard shortcuts

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