operator

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package operator is the top-level Operator abstraction that implement the declarative controller specifications.

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

Example usage:

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

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 Group

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

Group is a set of operators that share the same lifecycle and a common APIServer

func NewGroup

func NewGroup(config *rest.Config, logger logr.Logger) *Group

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

func (*Group) AddOperator

func (g *Group) AddOperator(name string, spec *opv1a1.OperatorSpec) (*Operator, error)

AddOperator registers an operator with the group.

func (*Group) DeleteOperator

func (g *Group) DeleteOperator(name string)

func (*Group) GetClient

func (g *Group) GetClient() client.Client

GetClient returns a controller runtime client that multiplexes all registered operator clients.

func (*Group) GetErrorChannel

func (g *Group) GetErrorChannel() chan error

GetErrorChannel returns the error channel the group uses to surface errors.

func (*Group) GetOperator

func (g *Group) GetOperator(name string) *Operator

GetOperator returns the operator with the given name.

func (*Group) SetAPIServer

func (g *Group) SetAPIServer(apiServer *apiserver.APIServer)

SetAPIServer allows to set the embedded API server shared by the operatos for this group. The API server lifecycle is not managed by the operator; make sure to run apiServer.Start before calling Start on the oparator group.

func (*Group) Start

func (g *Group) Start(ctx context.Context) error

Start starts the operators registered with the group. It blocks

func (*Group) UpsertOperator

func (g *Group) UpsertOperator(name string, spec *opv1a1.OperatorSpec) (*Operator, error)

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) ListControllers

func (op *Operator) ListControllers() []*dcontroller.Controller

ListControllers lists the controllers for the operator.

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) SetAPIServer

func (op *Operator) SetAPIServer(apiServer *apiserver.APIServer)

SetAPIServer allows to set the embedded API server. The API server lifecycle is not managed by the operator; make sure to run apiServer.Start before calling Start on the oparator.

func (*Operator) Start

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

Start starts the operator. It blocks

type Options

type Options struct {
	// 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

	// 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

	// 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