operator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package operator implements a Kubernetes controller to reconcile Operator CRD resources.

Package operator implements the top-level Operator controller that manages the lifecycle of declarative controller specifications.

The operator watches Operator custom resources and creates/manages the corresponding Δ-controllers based on their specifications. It provides the bridge between declarative YAML specifications and the imperative controller runtime.

Key components:

  • Operator: Main operator that manages controller lifecycles.
  • OperatorController: Kubernetes controller that reconciles Operator CRs.

The operator supports:

  • Dynamic controller creation from Operator CRs.
  • Lifecycle management (create, update, delete controllers).
  • Status reporting for managed controllers.
  • Optional API server integration for view object access.
  • Error handling and recovery.

Example usage:

op, _ := operator.NewFromFile("my-op", mgr, "operator.yaml", operator.Options{
    APIServer: server,
    Logger: logger,
})
return mgr.Add(op)

Index

Constants

View Source
const StatusChannelBufferSize = 64

StatusChannelBufferSize defines the longest backlog on the status channel.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {
	runtimeManager.Runnable
	reconcile.Reconciler
	GetManager() runtimeManager.Manager
	GetClient() client.Client
	SetAPIServer(*apiserver.APIServer)
}

Controller definition.

func NewController

func NewController(config *rest.Config, options runtimeManager.Options) (Controller, error)

NewController creates a new Kubernetes controller that handles the Operator CRDs.

type Operator

type Operator struct {
	// contains filtered or unexported fields
}

Operator definition.

func New

func New(name string, mgr runtimeMgr.Manager, spec *opv1a1.OperatorSpec, opts Options) *Operator

New creates a new operator.

func NewFromFile

func NewFromFile(name string, mgr runtimeMgr.Manager, file string, opts Options) (*Operator, error)

NewFromFile creates a new operator from a serialized operator spec.

func (*Operator) AddController

func (op *Operator) AddController(config opv1a1.Controller) error

AddController adds a new controller to the operator.

func (*Operator) GetController

func (op *Operator) GetController(name string) *dcontroller.Controller

GetController returns the controller with the given name or nil if no controller with that name exists.

func (*Operator) GetManager

func (op *Operator) GetManager() runtimeMgr.Manager

GetManager returns the controller runtime manager associated with the operator.

func (*Operator) GetName

func (op *Operator) GetName() string

GetName returns the name of the operator.

func (*Operator) GetStatus

func (op *Operator) GetStatus(gen int64) opv1a1.OperatorStatus

GetStatus populates the operator status with the controller statuses.

func (*Operator) RegisterGVKs

func (op *Operator) RegisterGVKs() error

RegisterGVKs registers the view resources associated with the conbtrollers run by operator in the extension API server.

func (*Operator) Start

func (op *Operator) Start(ctx context.Context) error

Start starts the operator. It blocks

func (*Operator) Trigger

func (op *Operator) Trigger(err error)

Trigger can be used to ask a status update trigger on the operator.

type Options

type Options struct {
	// API server is an optional extension server that can be used to interact with the view
	// objects stored in the operator cacache.
	APIServer *apiserver.APIServer

	// ErrorChannel is a channel to receive errors from the operator. Note that the error
	// channel is rate limited to at most 3 errors per every 2 seconds. Use ReportErrors on the
	// individual controllers to get the errors that might have been supporessed by the rate
	// limiter.
	ErrorChannel chan error

	// Logger is a standard logger.
	Logger logr.Logger
}

Options can be used to customize the Operator's behavior.

Jump to

Keyboard shortcuts

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